Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Dropdown follow wai-aria practices for expanding on arrow keys (#7277)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Dec 6, 2021
1 parent ca6feaa commit 7dfdb06
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/components/views/elements/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,22 @@ export default class Dropdown extends React.Component<IProps, IState> {
this.close();
break;
case Key.ARROW_DOWN:
this.setState({
highlightedOption: this.nextOption(this.state.highlightedOption),
});
if (this.state.expanded) {
this.setState({
highlightedOption: this.nextOption(this.state.highlightedOption),
});
} else {
this.setState({ expanded: true });
}
break;
case Key.ARROW_UP:
this.setState({
highlightedOption: this.prevOption(this.state.highlightedOption),
});
if (this.state.expanded) {
this.setState({
highlightedOption: this.prevOption(this.state.highlightedOption),
});
} else {
this.setState({ expanded: true });
}
break;
default:
handled = false;
Expand Down

0 comments on commit 7dfdb06

Please sign in to comment.