Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOO-809]: Implement a11y for pluggable widgets #21

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f7320b4
feat(accordion-native): add accessibility
UrazAkgultan Jan 3, 2023
091c5be
test(accordion-native): fix unit test
UrazAkgultan Jan 3, 2023
ccc256b
feat(activity-indicator-native): add accessibility
UrazAkgultan Jan 3, 2023
a573352
feat(badge-native): add accessibility
UrazAkgultan Jan 3, 2023
f6768fc
feat(bar-chart-native): add accessibility
UrazAkgultan Jan 3, 2023
359680f
feat(barcode-scanner-native): add accessibility
UrazAkgultan Jan 3, 2023
527c699
feat(column-chart-native): add accessibility
UrazAkgultan Jan 3, 2023
f1eb756
feat(image-native): add accessibility
UrazAkgultan Jan 3, 2023
cf8b140
feat(line-chart-native): add accessibility
UrazAkgultan Jan 3, 2023
864b02a
feat(pie-doughnut-chart-native): add accessibility
UrazAkgultan Jan 3, 2023
11d137e
feat(popup-menu-native): add accessibility
UrazAkgultan Jan 3, 2023
f3d6795
feat(progress-bar-native): add accessibility
UrazAkgultan Jan 3, 2023
4b1f990
feat(progress-circle-native): add accessibility
UrazAkgultan Jan 3, 2023
e90fa88
feat(qr-code-native): add accessibility
UrazAkgultan Jan 3, 2023
05fa51c
feat(radio-buttons-native): add accessibility
UrazAkgultan Jan 3, 2023
5f2440e
feat(range-slider-native): add accessibility
UrazAkgultan Jan 3, 2023
84c6cbf
feat(rating-native): add accessibility
UrazAkgultan Jan 3, 2023
447ceb1
feat(repeater-native): add accessibility
UrazAkgultan Jan 3, 2023
bdc2a3f
feat(safe-area-view-native): add accessibility
UrazAkgultan Jan 3, 2023
85585aa
feat(slider-native): add accessibility
UrazAkgultan Jan 3, 2023
93592d6
feat(switch-native): add accessibility
UrazAkgultan Jan 3, 2023
33c7541
feat(toggle-buttons-native): add accessibility
UrazAkgultan Jan 3, 2023
3d406f4
feat: add accessibility
UrazAkgultan Jan 22, 2023
1f4b46a
test: update unit tests snapshots
UrazAkgultan Jan 23, 2023
652e6e1
chroe: update CHANGELOG, bump widgets version
UrazAkgultan Jan 23, 2023
4ed3048
test(image-native): update unit test snapshot
UrazAkgultan Jan 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/pluggableWidgets/accordion-native/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Added

- Added accessibility.

## [2.2.0] - 2022-04-07

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/pluggableWidgets/accordion-native/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "accordion-native",
"widgetName": "Accordion",
"version": "2.2.0",
"version": "2.3.0",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export function getProperties(values: AccordionPreviewProps, defaultProperties:
if (group.groupCollapsed !== "groupStartDynamic") {
hidePropertyIn(defaultProperties, values, "groups", index, "groupCollapsedDynamic");
}
if (group.accessible !== "yes") {
hidePropertyIn(defaultProperties, values, "groups", index, "screenReaderCaption");
hidePropertyIn(defaultProperties, values, "groups", index, "screenReaderHint");
}
});

if (!values.collapsible) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function Accordion(props: Props): ReactElement | null {
}, [props.groups]);

return (
<View style={styles.container} testID={props.name}>
<View accessibilityRole="tablist" style={styles.container} testID={props.name}>
{props.groups.map(
(group, index): ReactElement => (
<AccordionGroup
Expand Down
60 changes: 36 additions & 24 deletions packages/pluggableWidgets/accordion-native/src/Accordion.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<widget id="com.mendix.widget.native.accordion.Accordion" supportedPlatform="Native" needsEntityContext="true"
offlineCapable="true"
pluginWidget="true"
xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../../../node_modules/mendix/custom_widget.xsd">
<?xml version="1.0" encoding="utf-8" ?>
<widget id="com.mendix.widget.native.accordion.Accordion" supportedPlatform="Native" needsEntityContext="true" offlineCapable="true" pluginWidget="true" xmlns="http://www.mendix.com/widget/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mendix.com/widget/1.0/ ../../../node_modules/mendix/custom_widget.xsd">
<name>Accordion</name>
<description>Toggle the display of sections of content</description>
<studioProCategory>Input elements</studioProCategory>
Expand All @@ -13,20 +9,20 @@
<propertyGroup caption="General">
<property key="groups" type="object" isList="true" required="true">
<caption>Groups</caption>
<description/>
<description />
<properties>
<propertyGroup caption="General">
<property key="headerRenderMode" type="enumeration" defaultValue="text">
<caption>Header type</caption>
<description/>
<description />
<enumerationValues>
<enumerationValue key="text">Text</enumerationValue>
<enumerationValue key="custom">Custom</enumerationValue>
</enumerationValues>
</property>
<property key="headerTextRenderMode" type="enumeration" defaultValue="heading5">
<caption>Render mode</caption>
<description/>
<description />
<enumerationValues>
<enumerationValue key="heading1">Heading 1</enumerationValue>
<enumerationValue key="heading2">Heading 2</enumerationValue>
Expand All @@ -38,28 +34,28 @@
</property>
<property key="headerText" type="textTemplate">
<caption>Text</caption>
<description/>
<description />
<translations>
<translation lang="en_US">Header</translation>
<translation lang="nl_NL">Koptekst</translation>
</translations>
</property>
<property key="headerContent" type="widgets" required="false">
<caption>Header</caption>
<description/>
<description />
</property>
<property key="content" type="widgets" required="false">
<caption>Content</caption>
<description/>
<description />
</property>
<property key="visible" type="expression" defaultValue="true">
<caption>Visible</caption>
<description/>
<returnType type="Boolean"/>
<description />
<returnType type="Boolean" />
</property>
<property key="groupCollapsed" type="enumeration" defaultValue="groupStartExpanded">
<caption>Start as</caption>
<description/>
<description />
<enumerationValues>
<enumerationValue key="groupStartExpanded">Expanded</enumerationValue>
<enumerationValue key="groupStartCollapsed">Collapsed</enumerationValue>
Expand All @@ -68,21 +64,37 @@
</property>
<property key="groupCollapsedDynamic" type="expression" required="false">
<caption>Collapsed expression</caption>
<description/>
<returnType type="Boolean"/>
<description />
<returnType type="Boolean" />
</property>
<property key="accessible" type="enumeration" defaultValue="no">
<caption>Accessible</caption>
<description />
<enumerationValues>
<enumerationValue key="yes">Yes</enumerationValue>
<enumerationValue key="no">No</enumerationValue>
</enumerationValues>
</property>
<property key="screenReaderCaption" type="textTemplate" required="false">
<caption>Screen reader caption</caption>
<description />
</property>
<property key="screenReaderHint" type="textTemplate" required="false">
<caption>Screen reader hint</caption>
<description />
</property>
</propertyGroup>
<propertyGroup caption="Events">
<property key="groupCollapsedAttribute" type="attribute" required="false">
<caption>Collapsed attribute</caption>
<description/>
<description />
<attributeTypes>
<attributeType name="Boolean"/>
<attributeType name="Boolean" />
</attributeTypes>
</property>
<property key="groupOnChange" type="action" required="false">
<caption>On change</caption>
<description/>
<description />
</property>
</propertyGroup>
</properties>
Expand All @@ -91,7 +103,7 @@
<propertyGroup caption="Behavior">
<property key="collapsible" type="boolean" defaultValue="true">
<caption>Collapsible</caption>
<description/>
<description />
</property>
<property key="collapseBehavior" type="enumeration" defaultValue="singleExpanded">
<caption>Expanded groups</caption>
Expand All @@ -106,7 +118,7 @@
<propertyGroup caption="Visualization">
<property key="icon" type="enumeration" defaultValue="right">
<caption>Show Icon</caption>
<description/>
<description />
<enumerationValues>
<enumerationValue key="right">Right</enumerationValue>
<enumerationValue key="left">Left</enumerationValue>
Expand All @@ -115,11 +127,11 @@
</property>
<property key="iconCollapsed" type="icon" required="false">
<caption>Icon collapsed</caption>
<description/>
<description />
</property>
<property key="iconExpanded" type="icon" required="false">
<caption>Icon expanded</caption>
<description/>
<description />
</property>
</propertyGroup>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const defaultProps = (): Props => ({
style: [],
groups: [
{
accessible: "yes",
headerRenderMode: "text",
headerTextRenderMode: "heading1",
headerText: dynamicValue<string>("Header1"),
Expand All @@ -23,6 +24,7 @@ const defaultProps = (): Props => ({
groupOnChange: actionValue()
},
{
accessible: "yes",
headerRenderMode: "custom",
headerTextRenderMode: "heading1",
headerText: dynamicValue<string>(undefined),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`Accordion in collapsible & single expanded group mode renders correctly 1`] = `
<View
accessibilityRole="tablist"
style={
Object {
"backgroundColor": "#FFF",
Expand All @@ -20,6 +21,12 @@ exports[`Accordion in collapsible & single expanded group mode renders correctly
}
>
<View
accessibilityLabel="Header1"
accessibilityState={
Object {
"expanded": false,
}
}
accessible={true}
collapsable={false}
focusable={true}
Expand Down Expand Up @@ -47,6 +54,7 @@ exports[`Accordion in collapsible & single expanded group mode renders correctly
}
>
<Text
accessible={true}
style={
Array [
Object {
Expand All @@ -64,6 +72,7 @@ exports[`Accordion in collapsible & single expanded group mode renders correctly
Header1
</Text>
<View
accessible={true}
style={
Object {
"height": 16,
Expand Down Expand Up @@ -115,6 +124,11 @@ exports[`Accordion in collapsible & single expanded group mode renders correctly
}
>
<View
accessibilityState={
Object {
"expanded": true,
}
}
accessible={true}
collapsable={false}
focusable={true}
Expand Down Expand Up @@ -142,6 +156,7 @@ exports[`Accordion in collapsible & single expanded group mode renders correctly
}
>
<View
accessible={true}
style={
Object {
"flex": 1,
Expand All @@ -153,6 +168,7 @@ exports[`Accordion in collapsible & single expanded group mode renders correctly
</Text>
</View>
<View
accessible={true}
style={
Object {
"height": 16,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,32 @@ export function AccordionGroup({
visible,
style
}: AccordionGroupProps): ReactElement | null {
const isAccessible = group.accessible === "yes";
return visible ? (
<View style={style.container}>
<Pressable
style={[style.header.container, icon === "left" && { flexDirection: "row-reverse" }]}
onPress={collapsible ? () => onPressGroupHeader(group, index) : null}
accessible={isAccessible}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is the right place to configure if the element is accessible or not, as if the accordion element is open by default then the children will be accessible still.

accessibilityLabel={
group.screenReaderCaption?.value ||
(group.headerRenderMode === "text" ? group.headerText.value : undefined)
}
accessibilityHint={group.screenReaderHint?.value}
accessibilityState={{ expanded: isExpanded }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use accessibilityElementsHidden and importantForAccessibility properties to disable all the children if the parent is disabled

>
{group.headerRenderMode === "text" ? (
<Text style={[style.header[group.headerTextRenderMode], { flex: 1 }]}>
<Text accessible={isAccessible} style={[style.header[group.headerTextRenderMode], { flex: 1 }]}>
{group.headerText.value}
</Text>
) : (
<View style={{ flex: 1 }}>{group.headerContent}</View>
<View accessible={isAccessible} style={{ flex: 1 }}>
{group.headerContent}
</View>
)}
{icon !== "no" && collapsible ? (
<GroupIcon
accessible={isAccessible}
isExpanded={isExpanded}
iconCollapsed={iconCollapsed}
iconExpanded={iconExpanded}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ interface GroupIconProps {
iconCollapsed: DynamicValue<NativeIcon> | undefined;
iconExpanded: DynamicValue<NativeIcon> | undefined;
style: AccordionIconStyle;
accessible: boolean;
}

export function GroupIcon({ iconCollapsed, iconExpanded, isExpanded, style }: GroupIconProps): ReactElement | null {
export function GroupIcon({
iconCollapsed,
iconExpanded,
isExpanded,
style,
accessible
}: GroupIconProps): ReactElement | null {
const customIconsConfigured = iconCollapsed?.value ?? iconExpanded?.value;
const customIconSource = iconCollapsed?.value || { type: "glyph", iconClass: "glyphicon-chevron-down" };
const customExpandedIconSource = iconExpanded?.value || { type: "glyph", iconClass: "glyphicon-chevron-up" };
Expand All @@ -41,11 +48,12 @@ export function GroupIcon({ iconCollapsed, iconExpanded, isExpanded, style }: Gr
}, [isExpanded, animatedValue]);

return customIconsConfigured ? (
<View style={iconStyles}>
<View accessible={accessible} style={iconStyles}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice if there is a caption for the icon

<Icon icon={source} size={style.size} color={style.color} />
</View>
) : (
<Animated.View
accessible={accessible}
style={[
iconStyles,
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="Accordion" version="2.2.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<clientModule name="Accordion" version="2.3.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="Accordion.xml" />
</widgetFiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export type HeaderTextRenderModeEnum = "heading1" | "heading2" | "heading3" | "h

export type GroupCollapsedEnum = "groupStartExpanded" | "groupStartCollapsed" | "groupStartDynamic";

export type AccessibleEnum = "yes" | "no";

export interface GroupsType {
headerRenderMode: HeaderRenderModeEnum;
headerTextRenderMode: HeaderTextRenderModeEnum;
Expand All @@ -21,6 +23,9 @@ export interface GroupsType {
visible: DynamicValue<boolean>;
groupCollapsed: GroupCollapsedEnum;
groupCollapsedDynamic?: DynamicValue<boolean>;
accessible: AccessibleEnum;
screenReaderCaption?: DynamicValue<string>;
screenReaderHint?: DynamicValue<string>;
groupCollapsedAttribute?: EditableValue<boolean>;
groupOnChange?: ActionValue;
}
Expand All @@ -38,6 +43,9 @@ export interface GroupsPreviewType {
visible: string;
groupCollapsed: GroupCollapsedEnum;
groupCollapsedDynamic: string;
accessible: AccessibleEnum;
screenReaderCaption: string;
screenReaderHint: string;
groupCollapsedAttribute: string;
groupOnChange: {} | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Added

- Added accessibility.

## [2.2.0] - 2022-04-07

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "activity-indicator-native",
"widgetName": "ActivityIndicator",
"version": "2.2.0",
"version": "2.3.0",
"license": "Apache-2.0",
"repository": {
"type": "git",
Expand Down
Loading