mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Simply logic for rendering matching accounts in to-autocomplete dropdown.
This commit is contained in:
parent
07c4c92db6
commit
ef2b0d8485
@ -62,25 +62,17 @@ ToAutoComplete.prototype.handleInputEvent = function (event = {}, cb) {
|
||||
openDropdown,
|
||||
} = this.props
|
||||
|
||||
const matchingAccounts = accounts.filter(({ address }) => address.match(to))
|
||||
const matchingAccounts = accounts.filter(({ address }) => address.match(to || ''))
|
||||
const matches = matchingAccounts.length
|
||||
|
||||
if (!to) {
|
||||
this.setState({ accountsToRender: accounts })
|
||||
openDropdown()
|
||||
}
|
||||
else if (matchingAccounts.length === 1 && matchingAccounts[0].address === to) {
|
||||
if (!matches || matchingAccounts[0].address === to) {
|
||||
this.setState({ accountsToRender: [] })
|
||||
event.target && event.target.select()
|
||||
closeDropdown()
|
||||
}
|
||||
else if (matchingAccounts.length) {
|
||||
this.setState({ accountsToRender: matchingAccounts })
|
||||
openDropdown()
|
||||
}
|
||||
else {
|
||||
this.setState({ accountsToRender: [] })
|
||||
event.target && event.target.select()
|
||||
closeDropdown()
|
||||
this.setState({ accountsToRender: matchingAccounts })
|
||||
openDropdown()
|
||||
}
|
||||
cb && cb(event.target.value)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user