fix(ui): keep Activity tab underline in sync#30640
Conversation
Fixes incorrect underline position on Activity when conditional tabs (e.g. Perps) mount/unmount after network filter changes. Fixes #30365 Relates-to: TMCU-755
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #30640 +/- ##
==========================================
+ Coverage 82.28% 82.31% +0.03%
==========================================
Files 5525 5539 +14
Lines 148957 149153 +196
Branches 34320 34355 +35
==========================================
+ Hits 122568 122781 +213
+ Misses 18033 18012 -21
- Partials 8356 8360 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 95008f0. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
The changes fix: sparse array layout measurement bugs, tab remounting strategy (using SmokeConfirmations, SmokeAccounts, SmokeSwap, SmokeStake, SmokeNetworkExpansion, SmokeNetworkAbstractions, SmokeMultiChainAPI, SmokeBrowser, SmokeSnaps, SmokeIdentity, SmokeSeedlessOnboarding are not directly affected as they don't primarily rely on the TabsBar component for their core flows. Performance Test Selection: |
|
There was a problem hiding this comment.
Tested on iPhone 15 Pro simulator
To trigger the tab add/remove scenario, temporarily modified isPerpsEnabled to toggle with the network filter (Popular networks = 4 tabs, single network = 3 tabs), which is the condition that drives the bug.
Underline tracking: pass
- Removed Perps (4→3 tabs): underline correctly snapped to Transactions even though Perps (index 2) was the previously active tab
- Re-added Perps (3→4 tabs): underline stayed on Transactions and correctly followed to Transfers on tap
- No stuck underline observed in any transition
Overflow scroll detection: pass
- Tab bar was scrollable in the 4-tab overflow state throughout, including after a 3→4 tab structural change


Description
Fixes the Activity tab underline getting stuck on the wrong tab after changing the network filter, when conditional tabs (e.g. Perps) are added or removed.
Detailed explanation (root cause and fix)
Root cause
The underline position is driven by measurements captured in
tabLayouts.currentand updated byonLayoutcallbacks inTabsBar.When the set of tabs changes (for example, Perps becomes enabled/disabled after a network filter change),
TabsBarwas resettingtabLayouts.currentwithnew Array(tabs.length). This produces a sparse array.TabsBarthen usedArray.prototype.every(...)to determine that all tab layouts were available. On sparse arrays,every(...)skips holes, so the check could incorrectly returntrueeven when only a subset of tab layouts had actually been measured.That caused
layoutsReadyto becometrueprematurely and allowedanimateToTab(...)to run against incomplete layout data. In the common failure case, the underline would animate to the last-measured tab and then refuse to move when the user switched back to a tab whose layout entry was still missing, leaving the underline stuck on the wrong tab.Fix
This PR makes the layout readiness checks robust and ensures we re-measure after structural tab changes:
Use dense arrays for layout resets
new Array(n)withArray.from({ length: n }, () => undefined)so the array has no holes.Make "all measured" checks strict
areAllTabLayoutsMeasured(...), which requireslayouts.length === tabCountand that every slot is defined with a positive width.Force re-measurement when tabs change
layoutGenerationvalue that is incremented on structural tab changes and included in theTabkey so React remounts eachTaband reliably re-firesonLayoutafter add/remove.Recover underline position as soon as the active tab is measured
animateToTab(activeIdx)viarequestAnimationFrame, so the underline updates promptly even while other tabs are still measuring.What changed in practice
Changelog
CHANGELOG entry: Fixed a bug where the Activity tab underline could get stuck on the wrong tab after changing networks.
Related issues
Fixes: #30365
Relates-to: https://consensyssoftware.atlassian.net/browse/TMCU-755
Manual testing steps
Screenshots/Recordings
Before
Tab underline could remain under the wrong tab (e.g. Predictions) while Transactions content was shown, after changing the network filter.
After
Tab underline stays aligned with the active tab when conditional tabs are added or removed.
tab_bar_fixed.mp4
Pre-merge author checklist
TabsBarunit tests pass (55/55); no new tests required for layout measurement edge casePerformance checks (if applicable)
Pre-merge reviewer checklist
Note
Low Risk
Localized TabsBar layout/animation logic with no auth, data, or API impact; behavior change is limited to tab underline positioning and scroll detection timing.
Overview
Fixes the TabsBar animated underline staying on the wrong tab when the tab list changes (e.g. conditional Activity tabs appearing after a network filter change).
Layout state now uses dense arrays (
Array.from+undefinedslots) and a strictareAllTabLayoutsMeasuredhelper so sparse-array holes cannot make readiness checks pass early. On structural tab changes,layoutGenerationis bumped and included in eachTabkeyto remount tabs and re-fireonLayout, replacing the old container-width reset trick.handleTabLayoutrepositions the underline viarequestAnimationFrameas soon as the active tab has valid measurements, andactiveIndexanimation only runs when all layouts are truly measured.Reviewed by Cursor Bugbot for commit cb4c130. Bugbot is set up for automated code reviews on this repo. Configure here.