Skip to content

Commit

Permalink
DIG-12929: gi mulighet å ikke sette fokus på komponenten ved reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio Bartoli committed Sep 26, 2016
1 parent 9265441 commit f5ae9e5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/account-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,17 @@ export default class AccountSelector extends Component {
}
}

reset() {
// The inputfield looses focus when we click the reset button, so we need to give it back
this._accountInput.focus();

reset(setFocus = true ) {
const {onChange, onAccountSelected} = this.props;
const state = {...this.getBlankState(), showAccountSuggestions: true, resetField: true };
const state = {...this.getBlankState(), showAccountSuggestions: false, resetField: false };

if (setFocus) {
// The inputfield looses focus when we click the reset button, so we need to give it back
this._accountInput.focus();
state.showAccountSuggestions = true;
state.resetField = true;
}

this.setState(state, () => {
onChange(state.selectedAccount);
onAccountSelected(state.selectedAccount);
Expand Down Expand Up @@ -301,6 +306,7 @@ export default class AccountSelector extends Component {
const assignTo = name => component => { this[name] = component; };
const {locale, placeholder, id, ariaInvalid, noMatches} = this.props;
const {filteredAccounts, showAccountSuggestions, value, selectedAccount, showResetButton} = this.state;
console.log("show sugggestions?", showAccountSuggestions);
return (
<div
className="nfe-account-selector"
Expand Down

0 comments on commit f5ae9e5

Please sign in to comment.