diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-11-14 15:23:23 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-11-15 02:00:18 +0800 |
commit | adce627888c126bec2ea008ddae7187bfa143625 (patch) | |
tree | 89d7f6aa3a2e60d6e6f6850418e1a6747b35d280 /packages | |
parent | 7688037fb86334ec2913c6fa850b6514fd9986b8 (diff) | |
download | dexon-sol-tools-adce627888c126bec2ea008ddae7187bfa143625.tar.gz dexon-sol-tools-adce627888c126bec2ea008ddae7187bfa143625.tar.zst dexon-sol-tools-adce627888c126bec2ea008ddae7187bfa143625.zip |
fix(instant): match token search on prefix
Diffstat (limited to 'packages')
-rw-r--r-- | packages/instant/src/components/erc20_token_selector.tsx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/packages/instant/src/components/erc20_token_selector.tsx b/packages/instant/src/components/erc20_token_selector.tsx index afa3f84c3..78741a617 100644 --- a/packages/instant/src/components/erc20_token_selector.tsx +++ b/packages/instant/src/components/erc20_token_selector.tsx @@ -63,8 +63,10 @@ export class ERC20TokenSelector extends React.Component<ERC20TokenSelectorProps> if (_.isUndefined(searchQuery)) { return true; } - const stringToSearch = `${token.metaData.name} ${token.metaData.symbol}`; - return _.includes(stringToSearch.toLowerCase(), searchQuery.toLowerCase()); + const searchQueryLowerCase = searchQuery.toLowerCase(); + const tokenName = token.metaData.name.toLowerCase(); + const tokenSymbol = token.metaData.symbol.toLowerCase(); + return _.startsWith(tokenSymbol, searchQueryLowerCase) || _.startsWith(tokenName, searchQueryLowerCase); }; } |