Commit deb715d
authored
fix(ramps): cp-7.59.0 buildquote screen flickering (#22326)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
There was a flickering issue when changing the payment method on the buy
screen or the region on the sell screen.
To fix the payment method issue, we just needed to remove it from the
handleRegionChange dependency array.
To fix the region issue, we needed to store a reference to the
previously selected region and use that to check whether an update was
necessary.
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: null
## **Related issues**
Fixes: #22313
## **Manual testing steps**
```gherkin
Feature: Buy flow - Change payment method
Scenario: User changes the payment method during the Buy flow without UI flickering
Given the user is on the asset details screen
And a default payment method is selected
When the user taps the "Buy" button
And the bottom sheet appears
And the user taps "Buy" again in the bottom sheet
And the user taps "Payment Method"
And the user selects a different payment method
Then the selected payment method should update
And the UI should transition smoothly with no flickering
Feature: Sell flow - Change region
Scenario: User changes the region during the Sell flow without UI flickering
Given the user is on the asset details screen
And a default region is selected
When the user taps the "Buy" button
And the bottom sheet appears
And the user taps "Sell" in the bottom sheet
And the user taps "Region"
And the user selects a different region
Then the selected region should update
And the UI should transition smoothly with no flickering
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
payment method change issue:
https://github.com/user-attachments/assets/53af19a7-72d3-41c3-968d-703949572049
region change issue:
https://github.com/user-attachments/assets/cf85e687-a9ea-4606-a3e9-efbced95dc42
### **After**
<!-- [screenshots/recordings] -->
payment method change fix:
https://github.com/user-attachments/assets/2635c9fd-05dc-4a1f-83e2-c35723799290
region change fix:
https://github.com/user-attachments/assets/4b103f2e-b6fc-4517-af21-6888c0b6995f
## **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
- [x] 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**
- [ ] 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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Moves fiat-currency-on-region-change logic from BuildQuote to
useFiatCurrencies with previous-region checks, and adds tests to
validate behavior.
>
> - **Aggregator logic**:
> - **`useFiatCurrencies`**: Adds `usePrevious(selectedRegion)` and
effect to update `selectedFiatCurrencyId` when region changes only if
using the default currency; queries new region default and updates
selection.
> - Maintains existing behaviors for selecting default currency and
validating availability.
> - **UI**:
> - **`BuildQuote.tsx`**: Removes region-change fiat update effect and
`setSelectedFiatCurrencyId` usage; relies on `useFiatCurrencies` for
currency sync.
> - **Tests**:
> - **`useFiatCurrencies.test.ts`**: Adds tests for updating currency on
region change when using default currency, and not updating when a
custom currency is selected; includes `act` usage.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e902222. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 9ba9c85 commit deb715d
File tree
3 files changed
+134
-27
lines changed- app/components/UI/Ramp/Aggregator
- Views/BuildQuote
- hooks
3 files changed
+134
-27
lines changedLines changed: 0 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
143 | 142 | | |
144 | 143 | | |
145 | 144 | | |
| |||
183 | 182 | | |
184 | 183 | | |
185 | 184 | | |
186 | | - | |
187 | 185 | | |
188 | 186 | | |
189 | 187 | | |
| |||
245 | 243 | | |
246 | 244 | | |
247 | 245 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | 246 | | |
274 | 247 | | |
275 | 248 | | |
| |||
Lines changed: 104 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
325 | 326 | | |
326 | 327 | | |
327 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 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 | + | |
328 | 432 | | |
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
78 | 108 | | |
79 | 109 | | |
80 | 110 | | |
| |||
0 commit comments