Skip to content

refactor(perps): migrate perps modal routes to native stack#30486

Merged
weitingsun merged 1 commit into
mainfrom
wsun/migrate-perps-modal-to-native-stack
May 21, 2026
Merged

refactor(perps): migrate perps modal routes to native stack#30486
weitingsun merged 1 commit into
mainfrom
wsun/migrate-perps-modal-to-native-stack

Conversation

@weitingsun

@weitingsun weitingsun commented May 21, 2026

Copy link
Copy Markdown
Contributor

Description

Migrates the Perps modal navigators (PerpsModalStack and PerpsClosePositionBottomSheetStack) from @react-navigation/stack (JS stack) to @react-navigation/native-stack, matching the existing native PerpsScreenStack.

Why: The Perps screen stack is already native — the nested modal stacks were the last JS-stack holdouts inside app/components/UI/Perps/routes/index.tsx. Native stack uses platform navigators, which gives better performance, gesture handling, and a single consistent navigator API across the Perps surface. This also removes a few JS-stack-only workarounds (the zero-opacity cardStyleInterpolator trick on the tooltip stack, redundant per-screen cardStyle transparency).

What:

  • ModalStack = createStackNavigator()createNativeStackNavigator()
  • Navigator screen options swap clearStackNavigatorOptions + presentation: 'transparentModal' for clearNativeStackNavigatorOptions + transparentModalScreenOptions
  • PerpsClosePositionBottomSheetStack drops its presentation: 'modal' + cardStyleInterpolator overlay-clear hack in favor of the same native presets (semantically equivalent: transparent, non-dimming overlay)
  • Removes per-screen cardStyle: { backgroundColor: 'transparent' } (navigator-level contentStyle now covers it)
  • Drops the @react-navigation/stack import from this file
    MainNavigator's outer registration of Routes.PERPS.MODALS.ROOT is unchanged — the parent stack there is still JS-stack and continues to mount PerpsModalStackWithErrorGate via transparentModal.

Changelog

CHANGELOG entry:null

Related issues

Fixes:

Manual testing steps

Feature: Perps modal navigation on native stack
  Scenario: user opens the GTM modal from the wallet
    Given the Perps feature flag is enabled
    And the `@MetaMask:perpsGTMModalShown` storage flag is cleared
    When user opens the Wallet tab
    Then the Perps "What's new" modal appears full screen
    And tapping "Not now" returns to the wallet without errors
    And tapping "Try now" navigates to the Perps tutorial
  
Scenario: user closes all open positions
    Given the user is on Wallet → Perps tab
    And the user has at least one open position
    When user taps "Close all" in the Positions header
    Then the Close All Positions bottom sheet opens
    And dismissing it returns to the Perps tab with no leftover backdrop
  
Scenario: user cancels all open orders
    Given the user is on Wallet → Perps tab
    And the user has at least one pending order
    When user taps "Cancel all" in the Open orders header
    Then the Cancel All Orders bottom sheet opens and dismisses correctly
  
Scenario: user opens a close-position tooltip
    Given the user has an open position
    When user opens Close position from market details
    And user taps the info icon next to "Fees" or "You'll receive"
    Then the tooltip bottom sheet (PerpsClosePositionModals → PerpsTooltip) appears
    And tapping outside or the close button dismisses it without dimming the parent screen
  
Scenario: user opens the provider selector (multi-provider builds)
    Given multi-provider is enabled
    When user taps the provider badge in Perps
    Then the Select Provider modal opens with a transparent background
  
Scenario: user triggers cross-margin warning
    Given the user has a cross-margin position on the underlying exchange
    When user attempts to place an order on that market
    Then the Cross Margin Warning modal appears
  
Scenario: user enters deposit / trade confirmation
    Given the user is on the Perps trade flow
    When the Redesigned Confirmations screen mounts inside the Perps stack
    Then the header / transparent overlay behavior is unchanged from main

Screenshots/Recordings

Before

perps modal before

After

perps modal after

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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
Moderate risk because it changes navigation stack implementation and screen options for Perps modals, which could affect modal presentation/gestures and overlay behavior across key trading flows.

Overview
Migrates the Perps modal navigators in app/components/UI/Perps/routes/index.tsx from the JS stack (@react-navigation/stack) to createNativeStackNavigator, aligning them with the existing native Perps screen stack.

Updates modal/tooltip navigator screenOptions to use clearNativeStackNavigatorOptions + transparentModalScreenOptions, and removes JS-stack-only transparency/overlay workarounds (per-screen transparent cardStyle and the tooltip stack’s zero-opacity overlay interpolator).

Reviewed by Cursor Bugbot for commit 2e6c012. Bugbot is set up for automated code reviews on this repo. 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.

@metamaskbotv2 metamaskbotv2 Bot added the team-mobile-platform Mobile Platform team label May 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePreps
  • Risk Level: medium
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
The change is a navigation infrastructure refactoring in app/components/UI/Perps/routes/index.tsx. It migrates the ModalStack from createStackNavigator (JS-based) to createNativeStackNavigator (native), replacing clearStackNavigatorOptions with clearNativeStackNavigatorOptions + transparentModalScreenOptions, and removes redundant per-screen cardStyle options now handled at the navigator level.

This affects:

  1. PerpsModalStack: The main modal navigator for Perps screens (provider selector, modify action, adjust margin action, order type)
  2. PerpsClosePositionBottomSheetStack: The close position bottom sheet navigator

The risk is medium because while this is a refactoring (equivalent functionality), switching from JS stack to native stack navigator can have subtle behavioral differences in modal presentation, transparency, and animation on both iOS and Android. The Perps flows that use these modal screens need validation.

Tag selection rationale:

  • SmokePerps: Directly affected - Perps navigation routes changed, modal screens may behave differently
  • SmokeWalletPlatform: Required per SmokePerps tag description (Perps is a section inside the Trending tab)
  • SmokeConfirmations: Required per SmokePerps tag description (Add Funds deposits are on-chain transactions that go through confirmations)

Performance Test Selection:
The migration from JS-based createStackNavigator to createNativeStackNavigator for the Perps modal stack could impact rendering performance. Native stack navigators generally perform better, but the change in modal presentation mechanics (transparentModal presentation, animation changes) could affect the Perps flow performance metrics. @PerformancePreps covers perps market loading, position management, add funds flow, and order execution - all of which use the modified navigation routes.

View GitHub Actions results

@weitingsun weitingsun marked this pull request as ready for review May 21, 2026 00:37
@weitingsun weitingsun requested a review from a team as a code owner May 21, 2026 00:37
@sonarqubecloud

Copy link
Copy Markdown

@weitingsun weitingsun added this pull request to the merge queue May 21, 2026
Merged via the queue into main with commit 8c73d92 May 21, 2026
267 of 294 checks passed
@weitingsun weitingsun deleted the wsun/migrate-perps-modal-to-native-stack branch May 21, 2026 16:40
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-S team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants