diff --git a/CHANGELOG.md b/CHANGELOG.md index cd0c50688a..5aee4984ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ### Fixes +- [#3428](https://github.com/poanetwork/blockscout/pull/3428) - Fix address tokens search - [#3424](https://github.com/poanetwork/blockscout/pull/3424) - Fix display of long NFT IDs - [#3422](https://github.com/poanetwork/blockscout/pull/3422) - Fix contract reader: tuple type - [#3408](https://github.com/poanetwork/blockscout/pull/3408) - Fix (total) difficulty display diff --git a/apps/block_scout_web/assets/js/lib/token_balance_dropdown.js b/apps/block_scout_web/assets/js/lib/token_balance_dropdown.js index ebfd875142..5f07156d6d 100644 --- a/apps/block_scout_web/assets/js/lib/token_balance_dropdown.js +++ b/apps/block_scout_web/assets/js/lib/token_balance_dropdown.js @@ -1,5 +1,6 @@ import $ from 'jquery' import { formatAllUsdValues } from './currency' +import { TokenBalanceDropdownSearch } from './token_balance_dropdown_search' const tokenBalanceDropdown = (element) => { const $element = $(element) @@ -20,4 +21,12 @@ const tokenBalanceDropdown = (element) => { export function loadTokenBalanceDropdown () { $('[data-token-balance-dropdown]').each((_index, element) => tokenBalanceDropdown(element)) + + $('[data-token-balance-dropdown]').on('hidden.bs.dropdown', _event => { + $('[data-filter-dropdown-tokens]').val('').trigger('input') + }) + + $('[data-token-balance-dropdown]').on('input', function (event) { + TokenBalanceDropdownSearch(this, event) + }) } diff --git a/apps/block_scout_web/assets/js/lib/token_balance_dropdown_search.js b/apps/block_scout_web/assets/js/lib/token_balance_dropdown_search.js index ce31e0cb90..3a98e3031b 100644 --- a/apps/block_scout_web/assets/js/lib/token_balance_dropdown_search.js +++ b/apps/block_scout_web/assets/js/lib/token_balance_dropdown_search.js @@ -29,7 +29,7 @@ const hideEmptyType = (container) => { } } -const TokenBalanceDropdownSearch = (element, event) => { +export function TokenBalanceDropdownSearch (element, event) { const $element = $(element) const $tokensCount = $element.find('[data-tokens-count]') const $tokens = $element.find('[data-token-name]') @@ -41,11 +41,3 @@ const TokenBalanceDropdownSearch = (element, event) => { $tokensCount.html($tokensCount.html().replace(/\d+/g, $tokens.not('.d-none').length)) } - -$('[data-token-balance-dropdown]').on('hidden.bs.dropdown', _event => { - $('[data-filter-dropdown-tokens]').val('').trigger('input') -}) - -$('[data-token-balance-dropdown]').on('input', function (event) { - TokenBalanceDropdownSearch(this, event) -}) diff --git a/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs b/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs index 0f283a29c6..b2f8b61e33 100644 --- a/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs +++ b/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs @@ -373,8 +373,8 @@ defmodule BlockScoutWeb.ViewingAddressesTest do next |> AddressPage.click_balance_dropdown_toggle() |> AddressPage.fill_balance_dropdown_search("ato") - |> assert_has(AddressPage.token_balance(count: 2)) - |> assert_has(AddressPage.token_type(count: 2)) + |> assert_has(AddressPage.token_balance(count: 1)) + |> assert_has(AddressPage.token_type(count: 1)) |> assert_has(AddressPage.token_type_count(type: "ERC-721", text: "1")) end @@ -388,8 +388,8 @@ defmodule BlockScoutWeb.ViewingAddressesTest do next |> AddressPage.click_balance_dropdown_toggle() |> AddressPage.fill_balance_dropdown_search("T2") - |> assert_has(AddressPage.token_balance(count: 2)) - |> assert_has(AddressPage.token_type(count: 2)) + |> assert_has(AddressPage.token_balance(count: 1)) + |> assert_has(AddressPage.token_type(count: 1)) |> assert_has(AddressPage.token_type_count(type: "ERC-20", text: "1")) end