Commit 8a03f66
authored
fix(ramps): Preserve user-entered amount during Transak navigation reset -> cp-7.71.0 (#27742)
## **Description**
Fixes the Buy flow amount reverting from the user-entered value back to
the default $100 during the Transak native provider loading transition.
When a user enters a custom amount (e.g. $30) and taps Continue, the
Transak routing callbacks use `navigation.reset()` to rebuild the
navigation stack with a fresh `BuildQuote` screen as the base route.
This fresh instance initialized with `DEFAULT_AMOUNT = 100`, causing a
visible flash of $100 during the transition to the checkout/KYC screen.
The fix passes the current `quote.fiatAmount` as a route param
(`amount`) to the `AMOUNT_INPUT` base route in every
`navigation.reset()` call. `BuildQuote` now reads `params?.amount` as
the initial state, preserving the user-entered amount through stack
resets.
## **Changelog**
CHANGELOG entry: Fixed Buy flow amount input reverting to $100 during
Transak native provider checkout transition.
## **Related issues**
Fixes:
[TRAM-3348](https://consensyssoftware.atlassian.net/browse/TRAM-3348)
## **Manual testing steps**
```gherkin
Feature: Amount persists through Transak native provider checkout transition
Scenario: Custom amount does not revert to default during Continue loading
Given the user is on the Buy screen with Transak Native provider
And the default amount is $100
When the user changes the amount to $30
And the user taps Continue
Then the displayed amount remains $30 during the loading transition
And the amount does not flash back to $100
Scenario: Default amount is preserved when no custom amount is entered
Given the user is on the Buy screen with Transak Native provider
And the default amount is $100
When the user taps Continue without changing the amount
Then the displayed amount remains $100 throughout the flow
Scenario: Amount persists when navigating back from KYC/checkout screens
Given the user entered $50 and proceeded through Continue
When the user navigates back to the Buy screen
Then the amount input shows $50 (not $100)
```
## **Screenshots/Recordings**
### **Before**
<!-- Screenshot/video showing amount reverting from $30 to $100 during
loading -->
https://github.com/user-attachments/assets/ba7fb42b-c43a-43f8-b438-0484090d7895
### **After**
<!-- Screenshot/video showing amount staying at $30 during loading
transition -->
https://github.com/user-attachments/assets/6d60c1ae-f0eb-448b-b7f3-297efbce85df
https://github.com/user-attachments/assets/099ebf69-face-4bb0-8568-80357f59b35e
<img width="523" height="877" alt="Screenshot 2026-03-20 175035"
src="https://github.com/user-attachments/assets/6bebcd4a-c04d-40c6-90d4-7e50ed683824"
/>
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Updates Transak native-provider navigation/reset logic and initial
screen state; mistakes could regress Buy/KYC routing or amount display
during transitions, but changes are localized and covered by tests.
>
> **Overview**
> Fixes the Transak native Buy flow so the user-entered fiat amount is
preserved when the app uses `navigation.reset()` during KYC/checkout
transitions.
>
> `BuildQuote` now supports an `amount` route param to initialize the
amount state (and to prevent region defaults from overriding it), and
`useTransakRouting` propagates this amount through all reset-based
navigation paths (KYC approved → checkout, KYC forms, additional
verification, verify identity, and KYC webview). Tests are updated/added
to assert the amount is passed through routing callbacks and used as the
initial displayed value.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
a8bdee0. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 2bcd74c commit 8a03f66
6 files changed
Lines changed: 207 additions & 54 deletions
File tree
- app/components/UI/Ramp
- Views
- BuildQuote
- NativeFlow
- hooks
Lines changed: 36 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
405 | 440 | | |
406 | 441 | | |
407 | 442 | | |
| |||
725 | 760 | | |
726 | 761 | | |
727 | 762 | | |
728 | | - | |
| 763 | + | |
729 | 764 | | |
730 | 765 | | |
731 | 766 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| |||
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
151 | | - | |
152 | | - | |
153 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
154 | 161 | | |
155 | 162 | | |
156 | 163 | | |
157 | | - | |
158 | 164 | | |
159 | 165 | | |
160 | 166 | | |
| |||
573 | 579 | | |
574 | 580 | | |
575 | 581 | | |
576 | | - | |
| 582 | + | |
577 | 583 | | |
578 | 584 | | |
579 | 585 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
| 49 | + | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
0 commit comments