Skip to content

Commit 8c81622

Browse files
authored
Accessibility (#381)
* Set aria-role "switch" on toggleable buttons * Add missing aria labels
1 parent f32e2a4 commit 8c81622

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

src/RichTextEditor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export default class RichTextEditor extends Component {
154154
onTab={this._onTab}
155155
onChange={this._onChange}
156156
placeholder={placeholder}
157+
ariaLabel={placeholder || 'Edit text'}
157158
ref={(el) => {
158159
this.editor = el;
159160
}}

src/lib/EditorToolbar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export default class EditorToolbar extends Component {
152152
choices={choices}
153153
selectedKey={blockType}
154154
onChange={this._selectBlockType}
155+
aria-label={'Block type'}
155156
/>
156157
</ButtonGroup>
157158
);

src/lib/StyleButton.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default class StyleButton extends Component {
2727
iconName={iconName}
2828
onClick={this._onClick}
2929
focusOnClick={false}
30+
isSwitch={true}
3031
/>
3132
);
3233
}

src/ui/IconButton.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ type Props = {
1313
children?: ReactNode;
1414
className?: string;
1515
label?: string;
16+
isSwitch?: boolean;
1617
};
1718

1819
export default class IconButton extends Component {
1920
props: Props;
2021

2122
render() {
2223
let {props} = this;
23-
let {className, iconName, label, children, isActive, ...otherProps} = props;
24+
let {className, iconName, label, children, isActive, isSwitch, ...otherProps} = props;
2425
className = cx(className, {
2526
[styles.root]: true,
2627
[styles.isActive]: isActive,
2728
});
2829
return (
2930
<ButtonWrap>
30-
<Button {...otherProps} title={label} className={className}>
31+
<Button {...otherProps} title={label} className={className} role={isSwitch && 'switch'} aria-checked={isActive}>
3132
<span className={styles['icon-' + iconName]} />
3233
{/* TODO: add text label here with aria-hidden */}
3334
</Button>

0 commit comments

Comments
 (0)