From 7dfdb06627f205ad55c704790e97512e05f5f2b1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 6 Dec 2021 09:25:44 +0000 Subject: [PATCH] Dropdown follow wai-aria practices for expanding on arrow keys (#7277) --- src/components/views/elements/Dropdown.tsx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/views/elements/Dropdown.tsx b/src/components/views/elements/Dropdown.tsx index 54154c7f7b0..4a21898bed8 100644 --- a/src/components/views/elements/Dropdown.tsx +++ b/src/components/views/elements/Dropdown.tsx @@ -222,14 +222,22 @@ export default class Dropdown extends React.Component { 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;