Repository navigation
Commit 39957e8
authored
feat: refactor asset list controls and move them to tab bar when wide layout is used (#47747)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
Normally the Tokens, DeFi, and NFTs controls sit on their own row under
the account tabs. On wide layout, they now sit on the tab row to utilise
the additional space better.
The controls stay mounted and are portaled into a host node (via
`TabControls`) that the wide layout moves into the end of the tab bar
(the "tab end slot"). The slot sits in the sticky tab row, so the
controls stay put while the token table scrolls. The popup and a narrow
sidepanel keep the controls on the row below the tabs.
As part of this PR, I've done a refactor of the asset list control bar.
Each tab now composes only the controls it shows, rather than everything
being driven from the `asset-list-control-bar.tsx` file. MMDS components
replace legacy ones. Functionality is completely unchanged. An unused
prop `showTokensLink` was removed as it was never called with `false`
and always defaulted to `true`, therefore that path was never used.
Change made | Files affected
-- | --
Split out of asset-list-control-bar.tsx | asset-controls.tsx,
network-filter.tsx, sort-by-button.tsx, token-options-menu.tsx,
nft-options-menu.tsx, defi-options-menu.tsx, manage-tokens-button.tsx,
use-open-token-management.ts
Shared popover and refresh row | use-control-popover.ts,
options-menu.tsx, refresh-item.tsx
Moved the more button | import-control/import-control.tsx →
asset-list-control-bar/options-button.tsx
Removed the old composer | asset-list-control-bar.tsx,
asset-list-control-bar.test.tsx, asset-list-control-bar.stories.tsx,
index.ts, index.scss, import-control/index.ts
Removed showTokensLinks | asset-list.tsx, account-overview-tabs.tsx,
account-overview-non-evm.tsx
Tabs compose their own controls | asset-list.tsx, nfts-tab.tsx,
defi-tab.tsx, activity-list.tsx
Wide layout moves the row onto the tab bar | tab-controls.tsx,
tab-end-slot.ts, tabs.tsx, tabs.scss
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: Moved the network filter and asset controls onto the
account tab row in the wide layout
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/CEUX-1368
## **Manual testing steps**
1. Run the extension and open the home screen with the fullscreen
redesign on and the window at least 768px wide.
2. On Tokens, confirm the network filter, sort button, and more menu sit
on the tab row. Open sort and the more menu and confirm only one stays
open. Use Manage tokens and Refresh list.
3. On NFTs, confirm there is no sort button. On an EVM account, use
Import NFTs and Refresh. On a non-EVM account, confirm the more control
opens token management.
4. On DeFi with positions, confirm sort and the refresh menu. With no
positions, confirm sort is hidden. With DeFi V1, confirm there is no
more menu.
5. On Activity, confirm only the network filter is shown and it stays
under the tabs, not on the tab row.
6. Shrink the window below 768px, and open the popup. Confirm the
controls sit under the tabs again and the popup layout is unchanged.
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
Wide layout:
<img width="1204" height="802" alt="image"
src="https://github.com/user-attachments/assets/efc00c44-8453-4b09-8cef-45e3ea82574d"
/>
Wide layout after scrolling down (asset control bar is sticky in the tab
bar):
<img width="1204" height="803" alt="image"
src="https://github.com/user-attachments/assets/5edcad7e-77cd-4a3a-80fb-cae32967e980"
/>
Non-wide layout shows no change to existing asset control bar:
<img width="400" height="602" alt="image"
src="https://github.com/user-attachments/assets/7e59da9b-cd26-4f2f-9858-0c123583aa89"
/>
## **Pre-merge author checklist**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Large UI refactor that preserves network-filter side effects
(`setTokenNetworkFilter`, `setActiveNetwork`, enabled-network
fallbacks); regressions could affect filtering, refresh/actions, or
wide-layout stickiness without being obvious in unit tests.
>
> **Overview**
> Refactors the home asset control bar from a single
`AssetListControlBar` into composable pieces (`AssetControls`,
`NetworkFilter`, `SortByButton`, and tab-specific options menus) so
Tokens, NFTs, DeFi, and Activity each mount only the controls they need.
Shared popover behavior and “only one menu open” state live in
`AssetControls` / `useControlPopover`.
>
> On **wide layout**, controls stay mounted but **`TabControls`**
portals them into a new **tab end slot** on the sticky tab row; narrow
popup/sidepanel layouts keep controls in a row under the tabs. Activity
still uses only the network filter and does not move onto the tab bar.
>
> Removes the unused **`showTokensLinks`** prop and related tests,
deletes the old control-bar module/styles/stories, splits tests across
the new components, and updates tabs SCSS for the end-slot layout
instead of negative-margin `overview-tab-controls`.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
eabc20d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 2560458 commit 39957e8
44 files changed
Lines changed: 1802 additions & 1638 deletions
File tree
- test
- e2e/page-objects/pages/networks
- jest
- ui
- components
- app
- assets
- asset-list
- asset-list-control-bar
- import-control
- nfts/nfts-tab
- multichain/account-overview
- ui/tabs
- pages
- activity
- defi/pages
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | 175 | | |
180 | 176 | | |
181 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
0 commit comments