Skip to content

fix: use StackActions.push to navigate to trending token details#27707

Merged
GeorgeGkas merged 1 commit into
mainfrom
swaps-4271
Mar 20, 2026
Merged

fix: use StackActions.push to navigate to trending token details#27707
GeorgeGkas merged 1 commit into
mainfrom
swaps-4271

Conversation

@GeorgeGkas

@GeorgeGkas GeorgeGkas commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Description

Problem

When the user navigates to a token's details page and then opens Swap from there, the navigation stack looks like:

[Home → Asset(TokenA) → Bridge]

Tapping a trending token inside the Swap/Bridge screen calls navigation.navigate('Asset', tokenBParams). React Navigation's navigate traverses the stack looking for an existing matching route — it finds the already-present Asset(TokenA) screen and navigates back to it, dismissing the Bridge screen. The user ends up on the original token's details page instead of the tapped trending token's details page.

Fix

Replace navigation.navigate('Asset', ...) with navigation.dispatch(StackActions.push('Asset', ...)) in TrendingTokenRowItem. StackActions.push always creates a new screen instance regardless of what is already on the stack, so the navigation flows correctly forward to the tapped token. When push is dispatched from a nested navigator that does not register 'Asset' (e.g. BridgeScreenStack or ExploreHome), React Navigation bubbles the action up to the root modal stack which does register it — matching the behaviour already used in BridgeTokenSelector for the same reason.

Tests are updated to assert that navigation.dispatch is called with the correct StackActions.push action and that navigation.navigate is no longer called.

Changelog

CHANGELOG entry: Fixed tapping a trending token from the Swap screen dismissing Swap instead of opening the token details page

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-4271

Manual testing steps

Feature: Trending token navigation from Swap screen

  Background:
    Given I am logged into MetaMask Mobile
    And I have at least one token in my wallet

  Scenario: user navigates to a trending token from Swap opened via token details page
    Given I am on a token details page (e.g. mUSD)
    And I can see the "Swap" action button

    When user taps "Swap"
    Then the Swap screen opens
    And I can see a list of trending tokens

    When user taps on a trending token (e.g. Sigma)
    Then the Sigma token details page opens
    And the Swap screen is no longer visible

  Scenario: user navigates to a trending token from Swap opened directly (not from token details)
    Given I am on the Wallet home screen

    When user opens the Swap screen directly
    And user taps on a trending token (e.g. Everlyn Token)
    Then the Everlyn Token details page opens

  Scenario: user navigates to a trending token from the Explore tab
    Given I am on the Explore tab

    When user taps on a trending token
    Then the token details page for that token opens

Screenshots/Recordings

Before

Tapping a trending token from Swap (opened via token details page) dismisses Swap and returns to the original token details page.

After

Tapping a trending token from Swap navigates forward to the tapped token's details page.

Pre-merge author checklist

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.

Note

Medium Risk
Changes navigation behavior for trending token taps by forcing a new Asset screen onto the stack; risk is mainly UX/regression if the action doesn’t bubble correctly in some navigators.

Overview
Fixes trending-token taps to always open a new token details screen by replacing navigation.navigate('Asset', ...) with navigation.dispatch(StackActions.push('Asset', ...)) in TrendingTokenRowItem.

Updates TrendingTokenRowItem tests to mock dispatch and assert StackActions.push is used (and navigate is not), including cases where a popular network must be added first or navigation is suppressed on failure.

Written by Cursor Bugbot for commit e2f50ab. This will update automatically on new commits. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

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.

@metamaskbot metamaskbot added the team-swaps-and-bridge Swaps and Bridge team label Mar 19, 2026
@github-actions github-actions Bot added size-M risk-low Low testing needed · Low bug introduction risk labels Mar 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeWalletPlatform
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are limited to two files in the TrendingTokenRowItem component:

  1. TrendingTokenRowItem.tsx: Changed navigation from navigation.navigate('Asset', assetParams) to navigation.dispatch(StackActions.push('Asset', assetParams)). This is a targeted navigation fix to ensure a new Asset screen is always pushed onto the navigation stack when tapping a token in the Trending tab, preventing unintended dismissal of screens like Bridge.

  2. TrendingTokenRowItem.test.tsx: Unit test updates to match the new navigation behavior (checking mockDispatch with StackActions.push instead of mockNavigate).

Tag Selection Rationale:

  • SmokeWalletPlatform is the appropriate tag because the Trending discovery tab (including the Tokens section with TrendingTokenRowItem) is explicitly covered by this tag. The change affects how token navigation works from the Trending tab.
  • No other tags are needed: this is not a confirmation flow, not a swap/bridge flow initiation, not an account management change, and not a network/chain permission change.
  • The fix is low-risk — it's a navigation method change (navigate → push) that improves stack behavior without changing the destination or parameters passed.

Performance Test Selection:
No performance impact expected. The change is a navigation method switch (navigate → StackActions.push) which has negligible performance difference. No rendering, data loading, state management, or list rendering changes were made.

View GitHub Actions results

@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
16 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud

Copy link
Copy Markdown

@GeorgeGkas GeorgeGkas added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit fc85dc0 Mar 20, 2026
126 checks passed
@GeorgeGkas GeorgeGkas deleted the swaps-4271 branch March 20, 2026 11:21
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 20, 2026
@metamaskbot metamaskbot added the release-7.72.0 Issue or pull request that will be included in release 7.72.0 label Mar 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.72.0 Issue or pull request that will be included in release 7.72.0 risk-low Low testing needed · Low bug introduction risk size-M team-assets team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants