From 04366bac0e0e2a8a310d80e88b98fa8e6d6f4c68 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 3 Dec 2021 11:27:05 +0000 Subject: [PATCH] Dropdown follow wai-aria practices for expanding on arrow keys --- 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;