diff --git a/src/account-selector.js b/src/account-selector.js index 9881e4fb95..da2a475e68 100644 --- a/src/account-selector.js +++ b/src/account-selector.js @@ -145,10 +145,8 @@ export default class AccountSelector extends Component { // Prevent blur if an account is selected from the dropdown or if the reset button is pressed if (accountSelectedFromDropdown || resetField) { - this._accountInput.focus(); this.setState({ accountSelectedFromDropdown: false, - showAccountSuggestions: resetField, resetField: false, }); return; @@ -173,6 +171,7 @@ export default class AccountSelector extends Component { filteredAccounts, showResetButton: value.length > 0, showAccountSuggestions: true, + accountSelectedFromDropdown : false, }, () => onChange(value)); } @@ -215,6 +214,7 @@ export default class AccountSelector extends Component { if (account && this.state.showAccountSuggestions) { this.setState({ selectedAccount: account, + showResetButton : true, value: account.name, }, this.scrollHighlightedAccountIntoView); } @@ -289,6 +289,14 @@ export default class AccountSelector extends Component { return accounts.filter(accountFilter(value)); } + componentDidUpdate() { + const {accountSelectedFromDropdown, resetField} = this.state; + // Prevent blur if an account is selected from the dropdown or if the reset button is pressed + if (accountSelectedFromDropdown || resetField) { + this._accountInput.focus(); + } + } + render() { const assignTo = name => component => { this[name] = component; }; const {locale, placeholder, id, ariaInvalid, noMatches} = this.props;