-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: fix hideZeroBalance setting for asset list #36821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix hideZeroBalance setting for asset list #36821
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨💎 @MetaMask/metamask-assets (1 files, +24 -14)
|
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [2d27454]
UI Startup Metrics (1229 ± 64 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Token List Filter Fails On Setting Toggle
The useMemo
dependency array is missing shouldHideZeroBalanceTokens
. When the "hide zero balance tokens" setting is toggled, the token list doesn't recompute, leading to stale filtering results until another dependency changes.
ui/components/app/assets/token-list/token-list.tsx#L134-L147
metamask-extension/ui/components/app/assets/token-list/token-list.tsx
Lines 134 to 147 in 1e07196
// eslint-disable-next-line react-hooks/exhaustive-deps | |
}, [ | |
isEvm, | |
evmBalances, | |
multichainAssets, | |
networksToShow, | |
currentNetwork.chainId, | |
tokenSortConfig, | |
isMultichainAccountsState2Enabled, | |
accountGroupIdAssets, | |
// newTokensImported included in deps, but not in hook's logic | |
newTokensImported, | |
allEnabledNetworksForAllNamespaces, | |
]); |
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Results generated automatically by MetaMask CI |
Builds ready [1e07196]
UI Startup Metrics (1235 ± 64 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a simple test?
}); | ||
return assets | ||
.filter((asset) => { | ||
if (shouldHideZeroBalanceTokens && asset.balance === '0') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 isnt there a numeric value we can compare to? Instead of string?
Description
PR to fix hiding tokens with zero balance when the setting is enabled.
Changelog
CHANGELOG entry: Fixed a bug causing users to still see tokens with zero balance when the setting "hideTokensWithZeroBalance" is enabled.
Related issues
Fixes: #36764
Manual testing steps
Screenshots/Recordings
Before
After
Screen.Recording.2025-10-13.at.16.23.15.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Hides zero-balance tokens in the asset list when the setting is enabled, including for multichain accounts.
getShouldHideZeroBalanceTokens
to filter out assets withbalance === '0'
before mapping/sorting inui/components/app/assets/token-list/token-list.tsx
.useSelector
to honor the user setting across networks.Written by Cursor Bugbot for commit 1e07196. This will update automatically on new commits. Configure here.