Skip to content

Conversation

amitabh94
Copy link
Contributor

Description

This PR fixes an Android-specific issue where selecting a token, payment method, or region in ramps flows (deposit, buy, withdraw) would incorrectly navigate to the home screen instead of returning to the previous screen.

Problem:
On Android devices, when users selected an item in any ramps modal selector (token, payment method, region, state, fiat), the app would navigate to the home screen instead of returning to the BuildQuote screen. This was a critical regression affecting the entire ramps user experience on Android.

Root Cause:
A race condition occurred between:

  1. BottomSheet's automatic navigation.goBack() call (via shouldNavigateBack={true})
  2. Manual navigation triggered when closing the sheet

Both navigation actions fired simultaneously on Android, causing the navigation stack to become confused and navigate to the wrong screen.

Solution:

  • Disabled automatic navigation by setting shouldNavigateBack={false} on all ramps BottomSheet components
  • Implemented BottomSheet's callback pattern: onCloseBottomSheet(() => navigation.goBack())
  • This ensures navigation happens sequentially: sheet closes → animation completes → navigation occurs

This follows the intended BottomSheet usage pattern and eliminates the race condition.

Files Modified:

  • TokenSelectorModal.tsx (Deposit)
  • PaymentMethodSelectorModal.tsx (Deposit)
  • RegionSelectorModal.tsx (Deposit)
  • StateSelectorModal.tsx (Deposit)
  • TokenSelectModal.tsx (Aggregator - Buy/Sell)
  • RegionSelectorModal.tsx (Aggregator - Buy/Sell)
  • PaymentMethodSelectorModal.tsx (Aggregator - Buy/Sell)
  • FiatSelectorModal.tsx (Aggregator - Buy/Sell)

Changelog

CHANGELOG entry: Fixed Android issue where ramps modal selection navigated to home screen

Related issues

Fixes: #21350

Manual testing steps

Feature: Ramps Token Selection on Android

  Scenario: user selects a token in deposit flow
    Given user is on Android device
    And user is on the deposit BuildQuote screen

    When user taps on the token selector
    And user selects a different token from the list
    Then the token selector modal closes
    And user returns to the BuildQuote screen with the new token selected
    And user does NOT navigate to the home screen

  Scenario: user selects a payment method in buy flow
    Given user is on Android device
    And user is on the buy BuildQuote screen

    When user taps on the payment method selector
    And user selects a payment method from the list
    Then the payment method modal closes
    And user returns to the BuildQuote screen
    And user does NOT navigate to the home screen

  Scenario: user selects a region in deposit flow
    Given user is on Android device
    And user is on the deposit BuildQuote screen

    When user taps on the region selector
    And user selects a region from the list
    Then the region modal closes
    And user returns to the BuildQuote screen
    And user does NOT navigate to the home screen

Screenshots/Recordings

Before

Issue as reported in #21350 - selecting token navigates to home screen on Android

After

Expected behavior: selecting token closes modal and returns to BuildQuote screen

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.

Technical Details

Why This Fix Works

The BottomSheet component has a built-in callback system specifically designed for this use case:

// Before (Broken):
<BottomSheet ref={sheetRef} shouldNavigateBack={true}>
  onPress={() => sheetRef.current?.onCloseBottomSheet()}
</BottomSheet>

// After (Fixed):
<BottomSheet ref={sheetRef} shouldNavigateBack={false}>
  onPress={() => sheetRef.current?.onCloseBottomSheet(() => navigation.goBack())}
</BottomSheet>

The callback ensures:

  1. Sheet closing animation starts
  2. Animation completes
  3. Callback fires → navigation.goBack()
  4. Single, clean navigation action at the right time

Testing Impact

  • No unit test updates required (navigation is already mocked via renderScreen)
  • Manual testing on Android devices is critical
  • iOS behavior remains unchanged

Fixes #21350

This commit fixes an Android-specific issue where selecting a token,
payment method, or region in ramps flows (deposit, buy, withdraw)
would incorrectly navigate to the home screen instead of returning
to the previous screen.

Root Cause:
- Race condition between BottomSheet's automatic navigation
  (shouldNavigateBack={true}) and manual navigation.goBack() calls
- Both navigation actions fired simultaneously on Android
- Navigation stack became confused and navigated to wrong screen

Solution:
- Set shouldNavigateBack={false} on all ramps BottomSheet components
- Use BottomSheet's callback pattern: onCloseBottomSheet(() => navigation.goBack())
- This ensures navigation happens AFTER sheet closes, not during

Changes:
- Added useNavigation import to all affected modal components
- Updated all selector modal callbacks to use navigation.goBack() in callback
- Applied fix to deposit and aggregator (buy/sell) flows

Files Modified:
- TokenSelectorModal (Deposit)
- PaymentMethodSelectorModal (Deposit)
- RegionSelectorModal (Deposit)
- StateSelectorModal (Deposit)
- TokenSelectModal (Aggregator)
- RegionSelectorModal (Aggregator)
- PaymentMethodSelectorModal (Aggregator)
- FiatSelectorModal (Aggregator)

Testing:
- No unit test changes required (navigation already mocked)
- Manual testing required on Android devices
- iOS behavior unchanged
@amitabh94 amitabh94 added type-bug Something isn't working release-blocker This bug is blocking the next release Sev1-high An issue that may have caused fund loss or access to wallet in the past & may still be ongoing team-ramp issues related to Ramp features team-design-system All issues relating to design system in Mobile regression-RC-7.57.0 Regression bug that was found in release candidate (RC) for release 7.57.0 labels Oct 18, 2025
Copy link
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.

@amitabh94 amitabh94 added Run Smoke E2E Requires smoke E2E testing QA Passed QA testing has been completed and passed no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed labels Oct 18, 2025
@amitabh94 amitabh94 removed team-design-system All issues relating to design system in Mobile type-bug Something isn't working QA Passed QA testing has been completed and passed release-blocker This bug is blocking the next release Sev1-high An issue that may have caused fund loss or access to wallet in the past & may still be ongoing Run Smoke E2E Requires smoke E2E testing size-M regression-RC-7.57.0 Regression bug that was found in release candidate (RC) for release 7.57.0 labels Oct 18, 2025
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 45.00000% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.11%. Comparing base (944a916) to head (5236557).

Files with missing lines Patch % Lines
...components/FiatSelectorModal/FiatSelectorModal.tsx 20.00% 4 Missing ⚠️
...r/components/TokenSelectModal/TokenSelectModal.tsx 20.00% 4 Missing ⚠️
...s/Modals/TokenSelectorModal/TokenSelectorModal.tsx 20.00% 4 Missing ⚠️
...MethodSelectorModal/PaymentMethodSelectorModal.tsx 66.66% 2 Missing ⚠️
...onents/RegionSelectorModal/RegionSelectorModal.tsx 60.00% 2 Missing ⚠️
...MethodSelectorModal/PaymentMethodSelectorModal.tsx 60.00% 2 Missing ⚠️
...Modals/RegionSelectorModal/RegionSelectorModal.tsx 60.00% 2 Missing ⚠️
...s/Modals/StateSelectorModal/StateSelectorModal.tsx 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21394      +/-   ##
==========================================
- Coverage   77.12%   77.11%   -0.01%     
==========================================
  Files        3615     3615              
  Lines       89144    89168      +24     
  Branches    16861    16861              
==========================================
+ Hits        68748    68758      +10     
- Misses      15719    15732      +13     
- Partials     4677     4678       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
45.0% Coverage on New Code (required ≥ 80%)
21.1% Duplication on New Code (required ≤ 10%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed team-ramp issues related to Ramp features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Android: Ramp Deposit, Buy, Withdraw closes when token selected is changed

2 participants