Commit 1276506
chore(runway): cherry-pick fix: PerpsMarketList navigation, and performance optimizations in TabList cp-7.59.0 (#22458)
- fix: PerpsMarketList navigation, and performance optimizations in
TabList cp-7.59.0 (#22341)
## **Description**
Navigating from a subsection in the PerpHomeScreen should navigate to
the proper tab in the MarketList. This PR also introduces some
performance optimizations in the horizontal scroll view by memoizing
list items to reduce the memory footprint, leading to a snappier
behavior.
If we want further optimizations, we can remove swipe navigation, in
favor of just pressing the tabs and leaning into lazy loading more.
## **Changelog**
CHANGELOG entry: Fix PerpsMarketList navigation and improve performance
on swipeable list view
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-2039
## **Manual testing steps**
```gherkin
Feature: Perps Market List Tab Navigation
Scenario: user navigates to Stocks tab from home screen Explore stocks and commodities section
Given user is on the Perps home screen
And the "Explore stocks and commodities" section is visible
When user taps "See all" in the "Explore stocks and commodities" section
Then user is navigated to the Perps market list screen
And the "Stocks" tab is selected
And stocks and commodities markets are displayed
Scenario: user navigates to Crypto tab from home screen Explore crypto section
Given user is on the Perps home screen
And the "Explore crypto" section is visible
When user taps "See all" in the "Explore crypto" section
Then user is navigated to the Perps market list screen
And the "Crypto" tab is selected
And crypto markets are displayed
Scenario: user switches tabs by tapping tab bar
Given user is on the Perps market list screen
And the "All" tab is currently selected
And the market list is scrolled to the middle
When user taps the "Crypto" tab
Then the "Crypto" tab becomes active
And only crypto markets are displayed
And the market list is scrolled to the top
And no performance lag is observed
Scenario: user switches tabs by swiping
Given user is on the Perps market list screen
And the "All" tab is currently selected
When user swipes left on the market list
Then the "Crypto" tab becomes active
And the tab bar indicator animates to "Crypto"
And only crypto markets are displayed
And the swipe gesture is smooth without stuttering
Scenario: user swipes between multiple tabs quickly
Given user is on the Perps market list screen
And the "All" tab is currently selected
When user swipes left to the "Crypto" tab
And user swipes left again to the "Stocks" tab
Then the "Stocks" tab becomes active
And the tab bar indicator animates smoothly to "Stocks"
And stocks and commodities markets are displayed
And tab switching is instant without noticeable delay
Scenario: user returns to previously viewed tab
Given user is on the Perps market list screen
And the "Crypto" tab is currently selected
And user has previously viewed the "All" tab
When user taps the "All" tab
Then the "All" tab becomes active
And all markets (crypto, stocks, and commodities) are displayed
And the market list is scrolled to the top
And no re-rendering delay is observed
Scenario: user applies sub-filter on Stocks tab
Given user is on the Perps market list screen
And the "Stocks" tab is currently selected
And both stocks and commodities are displayed
When user taps the stocks/commodities filter dropdown
And user selects "Stocks only"
Then only equity markets are displayed
And commodity markets are hidden
And the filter updates instantly
Scenario: user switches away from Stocks tab with active sub-filter
Given user is on the Perps market list screen
And the "Stocks" tab is currently selected
And the sub-filter is set to "Stocks only"
When user taps the "Crypto" tab
And user taps back to the "Stocks" tab
Then the "Stocks" tab becomes active
And the sub-filter is reset to "All"
And both stocks and commodities are displayed
```
## **Screenshots/Recordings**
https://github.com/user-attachments/assets/9b8c5278-018a-4a42-89b6-ef0cbd3b647a
## **Pre-merge author checklist**
- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/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]
> Fixes navigation to the correct market tab (including
`stocks_and_commodities`) and refactors `PerpsMarketListView` for
smoother swipe/tab sync with memoized row items.
>
> - **Navigation/Filtering**:
> - `PerpsHomeView`: pass `marketType="stocks_and_commodities"` for
Stocks & Commodities section.
> - `PerpsMarketTypeSection`: add `stocks_and_commodities` type; "See
All" navigates with `defaultMarketTypeFilter` matching section type.
> - **Market List View (performance/UX)**:
> - Replace per-tab filtering/components with unified `displayMarkets`
(applies sub-filter only on `stocks_and_commodities`).
> - Implement programmatic scroll guard with
`isScrollingProgrammatically` to prevent tab/scroll feedback loops and
sync active tab on swipe/press.
> - Simplify tabs rendering: render list per tab using `displayMarkets`;
remove `tabsToRender` and related logic.
> - Update empty/error/loading and analytics conditions to use
`displayMarkets`; fade-in tied to `displayMarkets.length`.
> - **Components**:
> - `PerpsMarketRowItem`: export `React.memo(...)` for row memoization;
adjust tests to rerender with spread props.
> - **Tests**:
> - Update expectations for "See All" navigation to pass the specific
`defaultMarketTypeFilter` and accommodate memoized row rerenders.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2fc991c. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: abretonc7s
<107169956+abretonc7s@users.noreply.github.com>
Co-authored-by: Arthur Breton <arthur.breton@consensys.net>
Co-authored-by: Nicholas Smith <nick.smith@consensys.net>
Co-authored-by: dylanbutler1
<99672693+dylanbutler1@users.noreply.github.com>
[9e5d761](9e5d761)
Co-authored-by: Nick Gambino <35090461+gambinish@users.noreply.github.com>
Co-authored-by: abretonc7s <107169956+abretonc7s@users.noreply.github.com>
Co-authored-by: Arthur Breton <arthur.breton@consensys.net>
Co-authored-by: Nicholas Smith <nick.smith@consensys.net>
Co-authored-by: dylanbutler1 <99672693+dylanbutler1@users.noreply.github.com>1 parent 9aec0aa commit 1276506
6 files changed
Lines changed: 75 additions & 120 deletions
File tree
- app/components/UI/Perps
- Views
- PerpsHomeView
- PerpsMarketListView
- components
- PerpsMarketRowItem
- PerpsMarketTypeSection
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
261 | | - | |
| 261 | + | |
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| |||
Lines changed: 56 additions & 107 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
201 | 145 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
212 | 150 | | |
213 | 151 | | |
214 | 152 | | |
| |||
249 | 187 | | |
250 | 188 | | |
251 | 189 | | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | 190 | | |
266 | 191 | | |
267 | 192 | | |
| |||
294 | 219 | | |
295 | 220 | | |
296 | 221 | | |
297 | | - | |
| 222 | + | |
298 | 223 | | |
299 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
300 | 230 | | |
301 | 231 | | |
302 | 232 | | |
| |||
309 | 239 | | |
310 | 240 | | |
311 | 241 | | |
312 | | - | |
| 242 | + | |
313 | 243 | | |
314 | 244 | | |
315 | 245 | | |
316 | 246 | | |
317 | 247 | | |
318 | 248 | | |
| 249 | + | |
319 | 250 | | |
320 | 251 | | |
321 | 252 | | |
322 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
323 | 258 | | |
324 | 259 | | |
325 | 260 | | |
326 | 261 | | |
327 | | - | |
| 262 | + | |
328 | 263 | | |
329 | 264 | | |
330 | 265 | | |
331 | 266 | | |
332 | 267 | | |
333 | 268 | | |
334 | | - | |
| 269 | + | |
335 | 270 | | |
336 | 271 | | |
337 | 272 | | |
| |||
364 | 299 | | |
365 | 300 | | |
366 | 301 | | |
367 | | - | |
| 302 | + | |
368 | 303 | | |
369 | 304 | | |
370 | 305 | | |
371 | 306 | | |
372 | 307 | | |
373 | 308 | | |
374 | 309 | | |
375 | | - | |
| 310 | + | |
376 | 311 | | |
377 | 312 | | |
378 | 313 | | |
| |||
397 | 332 | | |
398 | 333 | | |
399 | 334 | | |
400 | | - | |
| 335 | + | |
401 | 336 | | |
402 | 337 | | |
403 | 338 | | |
| |||
415 | 350 | | |
416 | 351 | | |
417 | 352 | | |
418 | | - | |
| 353 | + | |
419 | 354 | | |
420 | 355 | | |
421 | 356 | | |
| |||
443 | 378 | | |
444 | 379 | | |
445 | 380 | | |
446 | | - | |
| 381 | + | |
447 | 382 | | |
448 | 383 | | |
449 | 384 | | |
| |||
478 | 413 | | |
479 | 414 | | |
480 | 415 | | |
481 | | - | |
| 416 | + | |
482 | 417 | | |
483 | 418 | | |
484 | 419 | | |
| |||
518 | 453 | | |
519 | 454 | | |
520 | 455 | | |
521 | | - | |
| 456 | + | |
522 | 457 | | |
523 | 458 | | |
524 | 459 | | |
| |||
527 | 462 | | |
528 | 463 | | |
529 | 464 | | |
530 | | - | |
| 465 | + | |
531 | 466 | | |
532 | 467 | | |
533 | 468 | | |
| |||
540 | 475 | | |
541 | 476 | | |
542 | 477 | | |
543 | | - | |
| 478 | + | |
544 | 479 | | |
545 | 480 | | |
546 | 481 | | |
| |||
553 | 488 | | |
554 | 489 | | |
555 | 490 | | |
556 | | - | |
| 491 | + | |
557 | 492 | | |
558 | | - | |
| 493 | + | |
559 | 494 | | |
560 | 495 | | |
561 | 496 | | |
562 | 497 | | |
563 | 498 | | |
564 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
565 | 514 | | |
566 | 515 | | |
567 | 516 | | |
568 | 517 | | |
569 | 518 | | |
570 | 519 | | |
571 | | - | |
| 520 | + | |
572 | 521 | | |
573 | 522 | | |
574 | 523 | | |
575 | | - | |
| 524 | + | |
576 | 525 | | |
577 | 526 | | |
578 | 527 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
393 | | - | |
| 393 | + | |
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | | - | |
| 400 | + | |
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
| 209 | + | |
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
| 264 | + | |
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| |||
0 commit comments