Skip to content

Commit

Permalink
Accessibility (#381)
Browse files Browse the repository at this point in the history
* Set aria-role "switch" on toggleable buttons

* Add missing aria labels
  • Loading branch information
will-ks committed Sep 16, 2020
1 parent f32e2a4 commit 8c81622
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/RichTextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export default class RichTextEditor extends Component {
onTab={this._onTab}
onChange={this._onChange}
placeholder={placeholder}
ariaLabel={placeholder || 'Edit text'}
ref={(el) => {
this.editor = el;
}}
Expand Down
1 change: 1 addition & 0 deletions src/lib/EditorToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export default class EditorToolbar extends Component {
choices={choices}
selectedKey={blockType}
onChange={this._selectBlockType}
aria-label={'Block type'}
/>
</ButtonGroup>
);
Expand Down
1 change: 1 addition & 0 deletions src/lib/StyleButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class StyleButton extends Component {
iconName={iconName}
onClick={this._onClick}
focusOnClick={false}
isSwitch={true}
/>
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/ui/IconButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ type Props = {
children?: ReactNode;
className?: string;
label?: string;
isSwitch?: boolean;
};

export default class IconButton extends Component {
props: Props;

render() {
let {props} = this;
let {className, iconName, label, children, isActive, ...otherProps} = props;
let {className, iconName, label, children, isActive, isSwitch, ...otherProps} = props;
className = cx(className, {
[styles.root]: true,
[styles.isActive]: isActive,
});
return (
<ButtonWrap>
<Button {...otherProps} title={label} className={className}>
<Button {...otherProps} title={label} className={className} role={isSwitch && 'switch'} aria-checked={isActive}>
<span className={styles['icon-' + iconName]} />
{/* TODO: add text label here with aria-hidden */}
</Button>
Expand Down

0 comments on commit 8c81622

Please sign in to comment.