Skip to content

Commit

Permalink
DIG-13025 Input field steals focus onBlur in IE. Set focus after rend…
Browse files Browse the repository at this point in the history
…er is complete
  • Loading branch information
Torgeir Pedersen Cook committed Sep 21, 2016
1 parent ee9331c commit 6139a21
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/account-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -173,6 +171,7 @@ export default class AccountSelector extends Component {
filteredAccounts,
showResetButton: value.length > 0,
showAccountSuggestions: true,
accountSelectedFromDropdown : false,
}, () => onChange(value));
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6139a21

Please sign in to comment.