From 9c4eb1d649f9887133651ea83643f7496994d202 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 16 Dec 2019 10:03:40 +0000 Subject: [PATCH] clean up new code --- src/components/views/elements/Dropdown.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/views/elements/Dropdown.js b/src/components/views/elements/Dropdown.js index 9b4181fe68..67a8663b3e 100644 --- a/src/components/views/elements/Dropdown.js +++ b/src/components/views/elements/Dropdown.js @@ -178,7 +178,7 @@ export default class Dropdown extends React.Component { } } - _onMenuOptionClick(dropdownKey) { + _close() { this.setState({ expanded: false, }); @@ -186,6 +186,10 @@ export default class Dropdown extends React.Component { if (this._button.current) { this._button.current.focus(); } + } + + _onMenuOptionClick(dropdownKey) { + this._close(); this.props.onOptionChange(dropdownKey); } @@ -203,13 +207,7 @@ export default class Dropdown extends React.Component { this.props.onOptionChange(this.state.highlightedOption); // fallthrough case Key.ESCAPE: - this.setState({ - expanded: false, - }); - // their focus was on the input, its getting unmounted, move it to the button - if (this._button.current) { - this._button.current.focus(); - } + this._close(); break; case Key.ARROW_DOWN: this.setState({