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

Commit

Permalink
Merge pull request #27 from misteinb/bugfix/toggle-needs-switch-role
Browse files Browse the repository at this point in the history
Bugfix/toggle needs switch role
  • Loading branch information
misteinb authored Aug 20, 2018
2 parents 7341e65 + 81b4f68 commit d0e00b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## v3.0.4
### Fixed
- toggle controls need switch role for screen readers
- prevent default and stop propagation for tooltip keyboard shortcut in form field

## v3.0.3
### Fixed
- screen reader support for calendar
Expand Down
3 changes: 3 additions & 0 deletions lib/components/Field/FormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,14 @@ export class FormField extends React.PureComponent<FormFieldProps, FormFieldStat
tooltipVisible: true
});
e.preventDefault();
e.stopPropagation();
// if the user pressed escape key, close the tooltip
} else if (e.keyCode === keyCodes.Escape) {
this.setState({
tooltipVisible: false
});
e.preventDefault();
e.stopPropagation();
}
}

Expand Down
6 changes: 5 additions & 1 deletion lib/components/Toggle/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface ToggleProps extends React.Props<ToggleType> {

/**
* Toggle button that is an on or off state
*
*
* @param props Control properties (defined in `ToggleProps` interface)
*/
export const Toggle: React.StatelessComponent<ToggleProps> = (props: ToggleProps) => {
Expand Down Expand Up @@ -64,6 +64,10 @@ export const Toggle: React.StatelessComponent<ToggleProps> = (props: ToggleProps
name={props.name}
autoFocus={props.autoFocus}
methodRef={props.autoFocus && autoFocusRef}
// https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_switch_role
// the switch role represents the states "on" and "off."
role='switch'
aria-checked={props.on}
attr={props.attr.button}
/>
<Attr.div className={css('toggle-switch')} attr={props.attr.switch}/>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure-iot/ux-fluent-controls",
"version": "3.0.3",
"version": "3.0.4",
"description": "Azure IoT Fluent React Controls",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down

0 comments on commit d0e00b9

Please sign in to comment.