Skip to content

fix(swaps): scroll bridge to top from trending token details#27928

Merged
bfullam merged 4 commits into
mainfrom
swaps-trending-swap-scroll
Mar 27, 2026
Merged

fix(swaps): scroll bridge to top from trending token details#27928
bfullam merged 4 commits into
mainfrom
swaps-trending-swap-scroll

Conversation

@bfullam

@bfullam bfullam commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Description

This fixes #27843, where opening Swap from a trending token details page could land the user back on Bridge with the view still scrolled down and the prefilled form off-screen. The fix adds a minimal scrollToTopOnNav route param for that navigation path and has BridgeView consume it once on focus so token-details Swap entry points return with the swap form visible at the top.

Changelog

CHANGELOG entry: Fixed a bug that kept the swap screen scrolled down after opening Swap from a trending token details page.

Related issues

Fixes: #27843

Manual testing steps

Feature: Swap navigation from trending token details

  Scenario: user opens swap from the token details action row
    Given the user is on the Home tab
    And the user opens Swap
    And the user scrolls to the Trending tokens list
    And the user opens a trending token details page
    When the user taps "Swap"
    Then the Bridge view opens with the prefilled swap form visible at the top of the screen

  Scenario: user opens swap from the token details sticky footer
    Given the user is on a trending token details page with the sticky footer visible
    When the user taps the sticky footer swap action
    Then the Bridge view opens with the prefilled swap form visible at the top of the screen

Screenshots/Recordings

Before

N/A

After

N/A

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

Low Risk
Low risk: adds a one-time navigation flag that triggers a ScrollView.scrollTo on focus and clears itself; scope is limited to swaps/bridge navigation and related tests.

Overview
Fixes a navigation UX bug where returning to BridgeView from Token Details (notably trending tokens) could leave the unified swap form scrolled off-screen.

This introduces a scrollToTopOnNav route param in useSwapBridgeNavigation, has BridgeView consume it via useFocusEffect to scroll the main ScrollView to y=0 and then setParams to clear the flag, and updates Token Details swap entry points (including sticky footer and buy/sell handlers) to request this behavior. Tests were updated/added to cover the new param propagation and one-time clearing.

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

@bfullam bfullam requested review from a team as code owners March 25, 2026 17:31
@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 25, 2026
@github-actions github-actions Bot added size-S risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread app/components/UI/TokenDetails/hooks/useTokenActions.test.ts Outdated
@bfullam bfullam changed the title Fix bridge scroll reset when navigating from trending token details fix(swaps): scroll bridge to top from trending token details Mar 25, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
@github-actions github-actions Bot added size-M risk-medium Moderate testing recommended · Possible bug introduction risk and removed size-S risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The PR introduces a scroll-to-top behavior when navigating from TokenDetails to BridgeView (swap/bridge screen). Specifically:

  1. BridgeView/index.tsx: Added useFocusEffect + scrollViewRef to scroll to top when scrollToTopOnNav route param is set, then clears the param.
  2. useSwapBridgeNavigation/index.ts: Added scrollToTopOnNav optional parameter to goToSwaps/goToNativeBridge functions, passed as route param.
  3. TokenDetails.tsx: Creates goToSwapsFromDetails wrapper that always passes scrollToTopOnNav: true.
  4. useTokenActions.ts: handleBuyPress and handleSellPress now pass scrollToTopOnNav: true to goToSwaps.

Tag selection rationale:

  • SmokeTrade: Directly affected - swap/bridge navigation flow from token details is modified. The scroll-to-top behavior on BridgeView navigation needs validation.
  • SmokeConfirmations: Required dependent tag per SmokeTrade description - swap/bridge flows require transaction confirmations.
  • SmokeWalletPlatform: TokenDetails is part of the wallet platform (token asset overview). The goToSwaps action from token details view is modified, affecting the token details → swap navigation path.

Not selected:

  • SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeAccounts, SmokeIdentity, etc.: No changes to network management, account management, or identity features.
  • FlaskBuildTests: No snap-related changes.
  • SmokeRamps, SmokeCard, SmokePerps, SmokePredictions, SmokeMultiChainAPI: Not affected by these navigation/scroll changes.

Performance Test Selection:
The changes are purely a UX scroll behavior fix - adding scroll-to-top when navigating from TokenDetails to BridgeView. This does not impact rendering performance, data loading, state management, or any performance-sensitive paths. No performance tests are warranted.

View GitHub Actions results

@github-actions

Copy link
Copy Markdown
Contributor

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

@sonarqubecloud

Copy link
Copy Markdown

@bfullam bfullam changed the title fix(swaps): scroll bridge to top from trending token details fix(swaps): scroll bridge to top from trending token details cp-7.71.0 Mar 25, 2026
@bfullam bfullam changed the title fix(swaps): scroll bridge to top from trending token details cp-7.71.0 fix(swaps): scroll bridge to top from trending token details Mar 25, 2026
@bfullam bfullam enabled auto-merge March 27, 2026 13:54
@bfullam bfullam added this pull request to the merge queue Mar 27, 2026
Merged via the queue into main with commit 81e9415 Mar 27, 2026
108 checks passed
@bfullam bfullam deleted the swaps-trending-swap-scroll branch March 27, 2026 14:21
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2026
@metamaskbot metamaskbot added the release-7.73.0 Issue or pull request that will be included in release 7.73.0 label Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.73.0 Issue or pull request that will be included in release 7.73.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-M team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

4 participants