Commit 286b012
authored
fix: reduce min/max amount validation flashing in build quote (#29360)
## **Description**
This PR fixes `TRAM-3472` on the Unified Buy V2 `BuildQuote` screen.
While a user is typing an amount, min/max provider-limit validation was
surfacing immediately on each intermediate value. That made the amount
input and inline error flash red while the user was still entering a
final valid number.
1. **What is the reason for the change?**
The visible limit error was tied directly to the live typed amount, so
transient values like `1` and `10` could momentarily render a min error
before the user finished typing `100`.
2. **What is the improvement/solution?**
Debounce the user-visible min/max error before rendering it, while
keeping the underlying validation immediate so invalid amounts still
block quote fetching and disable Continue right away.
## **Changelog**
CHANGELOG entry: Fixed excessive red flashing while entering buy amounts
near minimum and maximum provider limits.
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3472
## **Manual testing steps**
```gherkin
Feature: Buy amount limit validation does not flash while typing
Scenario: User types through transient below-min values toward a valid amount
Given the user is on the Build Quote screen
And the selected provider has a minimum purchase amount
When the user types an amount quickly toward a valid final value
Then the minimum purchase error should not flash red for the intermediate values
And the amount should settle without showing the error if the final value is valid
Scenario: User pauses on an invalid amount
Given the user is on the Build Quote screen
And the selected provider has a minimum or maximum purchase amount
When the user stops typing on an out-of-bounds amount
Then the corresponding min or max error should appear after the debounce delay
Scenario: User corrects an invalid amount back into range
Given the user can see a min or max purchase error on the Build Quote screen
When the user updates the amount so it is within the provider limits
Then the visible limit error should clear immediately
And quote fetching should resume for the valid amount
```
## **Screenshots/Recordings**
### **Before**
See ticket recording in `TRAM-3472`.
### **After**
https://www.loom.com/share/acff17a2f05c4b1ab576d9664821fda5
<!-- Add updated recording if needed. -->
## **Validation**
- `./node_modules/.bin/jest --runInBand --coverage
--collectCoverageFrom=app/components/UI/Ramp/Views/BuildQuote/BuildQuote.tsx
app/components/UI/Ramp/Views/BuildQuote/BuildQuote.test.tsx`
- `./node_modules/.bin/jest --runInBand
app/components/UI/Ramp/hooks/useProviderLimits.test.ts`
- `./node_modules/.bin/jest --runInBand
app/components/UI/Ramp/Views/BuildQuote/BuildQuote.test.tsx`
- `./node_modules/.bin/eslint
app/components/UI/Ramp/Views/BuildQuote/BuildQuote.tsx
app/components/UI/Ramp/Views/BuildQuote/BuildQuote.test.tsx`
- `./node_modules/.bin/prettier --check
app/components/UI/Ramp/Views/BuildQuote/BuildQuote.tsx
app/components/UI/Ramp/Views/BuildQuote/BuildQuote.test.tsx`
- Coverage on `BuildQuote.tsx`: 97.29% statements, 88.33% branches,
97.05% functions, 98.87% lines.
- `yarn lint:tsc` currently reports existing repo-wide type errors
outside this diff; no errors reference `BuildQuote.tsx` or
`BuildQuote.test.tsx`.
## **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.
#### Performance checks (if applicable)
- [ ] I've tested on Android
- [ ] I've tested with a power user scenario
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics
## **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]
> **Low Risk**
> Low risk UI/UX change: only delays rendering of min/max limit error
text while keeping the underlying limit validation immediate for quote
fetching and the Continue button.
>
> **Overview**
> Reduces *min/max provider limit error flashing* on the `BuildQuote`
amount input by debouncing the **user-visible** `amountLimitError` while
still using the immediate error to block quote fetching and disable
Continue.
>
> Updates tests to mock `useDebouncedValue` more generically and adds
coverage ensuring the limit error text is delayed, clears immediately
once valid, and quote-fetch gating remains immediate.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ae546a5. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 6b4a28e commit 286b012
2 files changed
Lines changed: 79 additions & 4 deletions
Lines changed: 74 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
| 361 | + | |
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
| |||
654 | 654 | | |
655 | 655 | | |
656 | 656 | | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
657 | 726 | | |
658 | 727 | | |
659 | 728 | | |
| |||
687 | 756 | | |
688 | 757 | | |
689 | 758 | | |
690 | | - | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
691 | 762 | | |
692 | 763 | | |
693 | 764 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
399 | 402 | | |
400 | 403 | | |
401 | 404 | | |
| |||
663 | 666 | | |
664 | 667 | | |
665 | 668 | | |
666 | | - | |
| 669 | + | |
| 670 | + | |
667 | 671 | | |
668 | 672 | | |
669 | 673 | | |
| |||
0 commit comments