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

Commit 7dfdb06

Browse files
authored
Dropdown follow wai-aria practices for expanding on arrow keys (#7277)
1 parent ca6feaa commit 7dfdb06

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/components/views/elements/Dropdown.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,22 @@ export default class Dropdown extends React.Component<IProps, IState> {
222222
this.close();
223223
break;
224224
case Key.ARROW_DOWN:
225-
this.setState({
226-
highlightedOption: this.nextOption(this.state.highlightedOption),
227-
});
225+
if (this.state.expanded) {
226+
this.setState({
227+
highlightedOption: this.nextOption(this.state.highlightedOption),
228+
});
229+
} else {
230+
this.setState({ expanded: true });
231+
}
228232
break;
229233
case Key.ARROW_UP:
230-
this.setState({
231-
highlightedOption: this.prevOption(this.state.highlightedOption),
232-
});
234+
if (this.state.expanded) {
235+
this.setState({
236+
highlightedOption: this.prevOption(this.state.highlightedOption),
237+
});
238+
} else {
239+
this.setState({ expanded: true });
240+
}
233241
break;
234242
default:
235243
handled = false;

0 commit comments

Comments
 (0)