Commit ea8495b
authored
fix(perps): prevent unwanted tab navigation in market details and ensure tab content is shown cp-7.59.0 (#22632)
<!--
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**
This PR addresses 2 issues
- The `goToTabIndex` unintentionally triggered the last tab active on
remount
- The `goToTabIndex` unintentionally makes the content not visible and
may need to be fixed in the TabList component
- goToTabIndex calls handleTabPress
- handleTabPress updates activeIndex
- Content loading is deferred via the useEffect, which uses
InteractionManager.runAfterInteractions()
- Rendering happens immediately, but the check `if (!isLoaded) return
null` means nothing renders until the InteractionManager callback
completes
Note: We may need to refactor PerpsMarketTabs
- as there are unused variables such as `onActiveTabChange`
- the order of the default active tab doesn't need to be passed from
parents, as the use-case is to always show Position > Orders > Overview
(always the first tab)
- etc
## **Changelog**
CHANGELOG entry: Fixed an issue where Perps market tabs could navigate
unexpectedly and could skip the rendering of a tab
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-1982
## **Manual testing steps**
```gherkin
Feature: Perps Market Tabs Navigation
Scenario: user switches between tabs in Perps market details
Given user is viewing a market with an open position and open orders
When user swipes between Position, Orders, and Statistics tabs
Then tabs should switch smoothly without unexpected navigation
And the selected tab should remain stable
And the tab should show a content
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
https://github.com/user-attachments/assets/20dfcaa6-6670-4305-a496-e1b329d3ea2b
### **After**
<!-- [screenshots/recordings] -->
https://github.com/user-attachments/assets/d58c3213-d11f-4a26-a49d-5747187369c5
## **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]
> Restricts programmatic tab navigation to test environments to prevent
unintended tab switching and missing content on remount.
>
> - **PerpsMarketTabs
(`app/components/UI/Perps/components/PerpsMarketTabs/PerpsMarketTabs.tsx`)**:
> - Gate programmatic tab sync to tests: only call
`tabsListRef.current.goToTabIndex(activeIndex)` in test mode
(`process.env.JEST_WORKER_ID || process.env.E2E`) to avoid unintended
navigation on remount.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
1465a34. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 585cf08 commit ea8495b
File tree
1 file changed
+4
-1
lines changed- app/components/UI/Perps/components/PerpsMarketTabs
1 file changed
+4
-1
lines changedLines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
688 | 688 | | |
689 | 689 | | |
690 | 690 | | |
691 | | - | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
692 | 695 | | |
693 | 696 | | |
694 | 697 | | |
| |||
0 commit comments