Skip to content

Commit

Permalink
feat(Select): support a11y. Close #327
Browse files Browse the repository at this point in the history
  • Loading branch information
bindoon committed Mar 27, 2019
1 parent 0789c92 commit 22a42e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/select/auto-complete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ class AutoComplete extends Base {
aria-expanded={this.state.visible}
{..._inputProps}
/>
<span className={`${prefix}sr-only`} aria-live="polite">
{this.state.srReader}
</span>
</span>
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/select/base.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export default class Base extends React.Component {
width: 100,
// current highlight key
highlightKey: null,
srReader: '',
};

bindCtx(this, [
Expand Down Expand Up @@ -365,7 +366,7 @@ export default class Base extends React.Component {
const highlightItem = this.dataStore.getEnableDS()[highlightIndex];
highlightKey = highlightItem ? `${highlightItem.value}` : null;

this.setState({ highlightKey });
this.setState({ highlightKey, srReader: highlightItem.label });

this.scrollMenuIntoView();

Expand Down
3 changes: 3 additions & 0 deletions src/select/select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,9 @@ class Select extends Base {
className={`${prefix}select-inner`}
ref={this.saveInputRef}
/>
<span className={`${prefix}sr-only`} aria-live="polite">
{this.state.srReader}
</span>
</span>
);
}
Expand Down

0 comments on commit 22a42e7

Please sign in to comment.