Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit d0e00b9

Browse files
authored
Merge pull request #27 from misteinb/bugfix/toggle-needs-switch-role
Bugfix/toggle needs switch role
2 parents 7341e65 + 81b4f68 commit d0e00b9

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG
22

3+
## v3.0.4
4+
### Fixed
5+
- toggle controls need switch role for screen readers
6+
- prevent default and stop propagation for tooltip keyboard shortcut in form field
7+
38
## v3.0.3
49
### Fixed
510
- screen reader support for calendar

lib/components/Field/FormField.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,14 @@ export class FormField extends React.PureComponent<FormFieldProps, FormFieldStat
9393
tooltipVisible: true
9494
});
9595
e.preventDefault();
96+
e.stopPropagation();
9697
// if the user pressed escape key, close the tooltip
9798
} else if (e.keyCode === keyCodes.Escape) {
9899
this.setState({
99100
tooltipVisible: false
100101
});
102+
e.preventDefault();
103+
e.stopPropagation();
101104
}
102105
}
103106

lib/components/Toggle/Toggle.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface ToggleProps extends React.Props<ToggleType> {
3636

3737
/**
3838
* Toggle button that is an on or off state
39-
*
39+
*
4040
* @param props Control properties (defined in `ToggleProps` interface)
4141
*/
4242
export const Toggle: React.StatelessComponent<ToggleProps> = (props: ToggleProps) => {
@@ -64,6 +64,10 @@ export const Toggle: React.StatelessComponent<ToggleProps> = (props: ToggleProps
6464
name={props.name}
6565
autoFocus={props.autoFocus}
6666
methodRef={props.autoFocus && autoFocusRef}
67+
// https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_switch_role
68+
// the switch role represents the states "on" and "off."
69+
role='switch'
70+
aria-checked={props.on}
6771
attr={props.attr.button}
6872
/>
6973
<Attr.div className={css('toggle-switch')} attr={props.attr.switch}/>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@azure-iot/ux-fluent-controls",
3-
"version": "3.0.3",
3+
"version": "3.0.4",
44
"description": "Azure IoT Fluent React Controls",
55
"main": "./lib/index.js",
66
"types": "./lib/index.d.ts",

0 commit comments

Comments
 (0)