From 6139a21dd313e6d0dcc8937d00d0764067cf117c Mon Sep 17 00:00:00 2001 From: Torgeir Pedersen Cook Date: Wed, 21 Sep 2016 13:13:51 +0200 Subject: [PATCH] DIG-13025 Input field steals focus onBlur in IE. Set focus after render is complete --- src/account-selector.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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;