fix(perps): Adjust navigation when returning from Perps asset view#41921
fix(perps): Adjust navigation when returning from Perps asset view#41921
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. |
Builds ready [c7735e0] [reused from 4ede4f5]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs
|
Pressing the back button on the market detail page always navigated to DEFAULT_ROUTE (wallet home), ignoring browser history. This caused two UX issues: 1. Returning from a market detail to the market list landed on home instead of the market list. 2. Scroll position was lost because navigate(route) resets the page rather than traversing history. Replacing with navigate(-1) traverses the browser history stack, restoring scroll position and returning to the correct previous screen.
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/perps (2 files, +3 -3)
|
|
Worker reportBug Fix Report — TAT-2965SummaryThe back button on the Perps market detail page always navigated to Root Cause
const handleBackClick = useCallback(() => {
navigate(DEFAULT_ROUTE); // always goes to home
}, [navigate]);This hard-navigates to the wallet home route regardless of what screen the user came from, discarding browser history and resetting scroll position. Changes
Test PlanAutomated:
Manual Gherkin steps: Evidence
TicketFixes: TAT-2965 Workflow Diagram (Mermaid) |
Builds ready [9bb3520]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs
|



Description
The back button on the Perps market detail page always navigated to
DEFAULT_ROUTE(wallet home), ignoring browser history. Changednavigate(DEFAULT_ROUTE)tonavigate(-1)inhandleBackClickso the browser traverses its history stack, returning users to the correct previous screen and restoring scroll position.Changelog
CHANGELOG entry: Fixed a bug where the back button on the Perps market detail page always redirected to wallet home instead of the previous screen.
Related issues
Fixes: TAT-2965
Manual testing steps
Screenshots/Recordings
Back button now returns to previous screen (market list or home) instead of always navigating to home.
Video
Videos show the full recipe run. Screenshots are sufficient to prove the fix.
before.mp4
after.mp4
Pre-merge author checklist
Pre-merge reviewer checklist
Validation Recipe
recipe.json
{ "title": "Perps back navigation — market list and home scroll position", "description": "Proves that pressing back on the market detail page returns the user to the correct previous screen (market list or wallet home) rather than always navigating to DEFAULT_ROUTE.", "validate": { "workflow": { "pre_conditions": ["wallet.unlocked", "perps.feature_enabled"], "entry": "setup-nav-perps", "nodes": { "setup-nav-perps": { "action": "call", "ref": "perps/navigate-perps-tab", "next": "setup-nav-market-list" }, "setup-nav-market-list": { "action": "navigate", "target": "PerpsMarketList", "next": "setup-wait-market-list" }, "setup-wait-market-list": { "action": "wait_for", "test_id": "market-list-view", "timeout_ms": 10000, "next": "setup-screenshot-market-list" }, "setup-screenshot-market-list": { "action": "screenshot", "filename": "evidence-ac1-before-market-list.png", "next": "setup-nav-to-detail" }, "setup-nav-to-detail": { "action": "call", "ref": "perps/navigate-to-market-detail", "params": { "symbol": "ETH" }, "next": "gate-wait-detail" }, "gate-wait-detail": { "action": "wait_for", "test_id": "perps-market-detail-page", "timeout_ms": 10000, "next": "ac1-screenshot-on-detail" }, "ac1-screenshot-on-detail": { "action": "screenshot", "filename": "evidence-ac1-on-market-detail.png", "next": "ac1-press-back" }, "ac1-press-back": { "action": "press", "test_id": "perps-market-detail-back-button", "next": "ac1-wait-for-market-list" }, "ac1-wait-for-market-list": { "action": "wait_for", "test_id": "market-list-view", "timeout_ms": 5000, "next": "ac1-assert-on-market-list" }, "ac1-assert-on-market-list": { "action": "eval_sync", "expression": "JSON.stringify({ onMarketList: !!document.querySelector('[data-testid=\"market-list-view\"]'), hash: window.location.hash })", "assert": { "all": [ { "operator": "eq", "field": "onMarketList", "value": true } ] }, "save_as": "back_nav_result", "next": "ac1-screenshot-back-result" }, "ac1-screenshot-back-result": { "action": "screenshot", "filename": "evidence-ac1-after-back-on-market-list.png", "next": "setup-nav-home-for-ac2" }, "setup-nav-home-for-ac2": { "action": "navigate", "target": "Home", "next": "setup-wait-home" }, "setup-wait-home": { "action": "wait_for", "test_id": "account-menu-icon", "timeout_ms": 10000, "next": "setup-screenshot-home" }, "setup-screenshot-home": { "action": "screenshot", "filename": "evidence-ac2-on-home.png", "next": "setup-nav-detail-from-home" }, "setup-nav-detail-from-home": { "action": "call", "ref": "perps/navigate-to-market-detail", "params": { "symbol": "BTC" }, "next": "gate-wait-detail-ac2" }, "gate-wait-detail-ac2": { "action": "wait_for", "test_id": "perps-market-detail-page", "timeout_ms": 10000, "next": "ac2-screenshot-detail" }, "ac2-screenshot-detail": { "action": "screenshot", "filename": "evidence-ac2-on-market-detail.png", "next": "ac2-press-back" }, "ac2-press-back": { "action": "press", "test_id": "perps-market-detail-back-button", "next": "ac2-wait-for-home" }, "ac2-wait-for-home": { "action": "wait_for", "test_id": "account-menu-icon", "timeout_ms": 5000, "next": "ac2-assert-on-home" }, "ac2-assert-on-home": { "action": "eval_sync", "expression": "JSON.stringify({ onHome: !!document.querySelector('[data-testid=\"account-menu-icon\"]'), notOnDetail: !document.querySelector('[data-testid=\"perps-market-detail-page\"]'), hash: window.location.hash })", "assert": { "all": [ { "operator": "eq", "field": "onHome", "value": true }, { "operator": "eq", "field": "notOnDetail", "value": true } ] }, "save_as": "home_back_nav_result", "next": "ac2-screenshot-back-home" }, "ac2-screenshot-back-home": { "action": "screenshot", "filename": "evidence-ac2-after-back-on-home.png", "next": "done" }, "done": { "action": "end", "status": "pass", "message": "Back navigation from market detail returns to correct previous screen" } } } } }Recipe Workflow
workflow.mmd
Note
Low Risk
Low risk UI navigation change: the Perps market detail back button now traverses browser history instead of hard-routing to home, with a corresponding test update.
Overview
Fixes the Perps market detail page back button to call
navigate(-1)(history back) rather than always routing toDEFAULT_ROUTE, preserving the user’s previous context.Updates the associated unit test to assert history navigation (
-1) and clarifies the test name accordingly.Reviewed by Cursor Bugbot for commit 9bb3520. Bugbot is set up for automated code reviews on this repo. Configure here.