Skip to content

Commit

Permalink
DIG-12261 Bugfix missing X when preset account. UX fix to presist foc…
Browse files Browse the repository at this point in the history
…us upon account selection.
  • Loading branch information
Henrik Hermansen committed Aug 25, 2016
1 parent 995418f commit 323ecab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog
# v.1.4.1
# v.1.4.2
* Bugfix: React warning when no selectedAccount or value props are given
* Bugfix: Missing X (reset) when selectedAccount or value are given
* UX: Focus will remain in the input when account is selected (except when tab is pressed)

## v.1.4.1
* Added callback to onAccountSelected with null account when the input is reset by user

## v.1.4.0
Expand Down
11 changes: 8 additions & 3 deletions src/account-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export default class AccountSelector extends Component {
getDefaultState() {
const {accounts, selectedAccount, value} = {...this.defaultProps, ...this.props};
const filteredAccounts = this.filterAccounts(accounts, value);
return {...this.getBlankState(), selectedAccount, value, filteredAccounts};
const showResetButton = !!(selectedAccount || value);
const showAccountSuggestions = false;
return {showAccountSuggestions, showResetButton, selectedAccount, value, filteredAccounts};
}

getBlankState() {
Expand Down Expand Up @@ -156,10 +158,13 @@ export default class AccountSelector extends Component {
}, () => onChange(value));
}

onAccountSelect(account) {
onAccountSelect(account, focus) {
const {accounts, onChange, onAccountSelected} = this.props;
const {accountNumber} = account;
const filteredAccounts = this.filterAccounts(accounts, accountNumber);
if (focus) {
this._accountInput.focus();
}
this.setState({
filteredAccounts,
value: account.name,
Expand Down Expand Up @@ -326,7 +331,7 @@ export default class AccountSelector extends Component {
<AccountSuggestionList
locale={locale}
accounts={ filteredAccounts }
onSelect={ this.onAccountSelect }
onSelect={ (account) => this.onAccountSelect(account, true) }
selectedAccount={ selectedAccount }
ref={ assignTo('_suggestionList') }
/>
Expand Down

0 comments on commit 323ecab

Please sign in to comment.