Commit 9f9609f
authored
fix(card): cp-7.60.0 fix OTP inputs frozen screens (#22894)
<!--
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**
<!--
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?
-->
Fixed critical OTP input freezing issues affecting three Card
onboarding/authentication screens where users were unable to navigate,
proceed, or sometimes even focus the 6-digit OTP input field.
**Problem:**
Users experienced UI freezing on OTP verification screens, preventing
them from:
- Focusing the OTP input field
- Navigating back to previous screens
- Proceeding after entering the verification code
**Root Cause:**
The implementations were missing the `useBlurOnFulfill` hook from
`react-native-confirmation-code-field`, which is critical for proper
input lifecycle management. Without this hook:
- The input field remained focused after all digits were entered
- The keyboard wasn't properly dismissed
- Focus conflicts caused the UI to freeze
- Navigation became blocked
**Solution:**
- Added `useBlurOnFulfill` hook to properly manage OTP input focus and
blur events
- Updated ref handling to use the hook's return value instead of manual
useRef
- Fixed hook dependency arrays to prevent stale closure issues
- Fixed a cooldown timing bug in ConfirmPhoneNumber (was setting
cooldown before API success)
- Updated all test mocks to include the new hook
The implementation now matches the working pattern used in the
Ramp/Deposit OTP screen (OtpCode.tsx), which doesn't experience these
issues.
## **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: Fixed OTP input freezing issues on Card email and phone
verification screens
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: my feature name
Scenario: user [verb for user action]
Given [describe expected initial app state]
When user [verb for user action]
Then [describe expected outcome]
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **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]
> Integrates useBlurOnFulfill for OTP fields, adds platform-specific
autocomplete, refactors focus/refs, and fixes resend cooldown timing;
updates tests and mocks accordingly.
>
> - **Card OTP flows**
> - Use `useBlurOnFulfill` for `CodeField` in `CardAuthentication`,
`ConfirmEmail`, and `ConfirmPhoneNumber` to manage focus/blur and
prevent freezes.
> - Replace manual `useRef` with hook-provided refs; update focus
effects and dependency arrays.
> - Add platform-specific `autoComplete` (`android: 'sms-otp'`, default:
`'one-time-code'`) and type `TextInputProps`.
> - Cast `CodeField` refs to `React.RefObject<TextInput>`.
> - **Resend/cooldown behavior**
> - In `ConfirmPhoneNumber`, set cooldown after successful resend;
maintain guard against rapid presses with `resendInProgressRef`.
> - In `CardAuthentication`/`ConfirmEmail`, ensure countdown timers and
resend handlers respect cooldown state.
> - **Tests**
> - Update `react-native-confirmation-code-field` mocks to include
`useBlurOnFulfill` in related test files.
> - Minor adjustments (e.g., variable rename for
`contactVerificationId`) to align with implementation.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
158a841. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 44c33a8 commit 9f9609f
File tree
6 files changed
+164
-40
lines changed- app/components/UI/Card
- Views/CardAuthentication
- components/Onboarding
6 files changed
+164
-40
lines changedLines changed: 80 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
108 | 188 | | |
109 | 189 | | |
110 | 190 | | |
| |||
Lines changed: 16 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 2 | + | |
9 | 3 | | |
10 | 4 | | |
11 | 5 | | |
| |||
15 | 9 | | |
16 | 10 | | |
17 | 11 | | |
| 12 | + | |
18 | 13 | | |
19 | 14 | | |
20 | 15 | | |
| |||
46 | 41 | | |
47 | 42 | | |
48 | 43 | | |
| 44 | + | |
49 | 45 | | |
50 | 46 | | |
51 | 47 | | |
| |||
56 | 52 | | |
57 | 53 | | |
58 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | 105 | | |
107 | 106 | | |
108 | 107 | | |
| |||
174 | 173 | | |
175 | 174 | | |
176 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
177 | 182 | | |
178 | 183 | | |
179 | 184 | | |
180 | 185 | | |
181 | 186 | | |
182 | | - | |
| 187 | + | |
183 | 188 | | |
184 | 189 | | |
185 | 190 | | |
| |||
360 | 365 | | |
361 | 366 | | |
362 | 367 | | |
363 | | - | |
| 368 | + | |
364 | 369 | | |
365 | 370 | | |
366 | 371 | | |
367 | 372 | | |
368 | 373 | | |
369 | 374 | | |
370 | 375 | | |
371 | | - | |
| 376 | + | |
372 | 377 | | |
373 | 378 | | |
374 | 379 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
244 | 252 | | |
245 | 253 | | |
246 | 254 | | |
247 | 255 | | |
| 256 | + | |
248 | 257 | | |
249 | 258 | | |
250 | 259 | | |
| |||
Lines changed: 23 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 1 | + | |
8 | 2 | | |
9 | 3 | | |
10 | 4 | | |
| |||
38 | 32 | | |
39 | 33 | | |
40 | 34 | | |
41 | | - | |
| 35 | + | |
42 | 36 | | |
43 | 37 | | |
44 | 38 | | |
| 39 | + | |
45 | 40 | | |
46 | 41 | | |
47 | 42 | | |
48 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
49 | 48 | | |
50 | 49 | | |
51 | 50 | | |
| |||
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | | - | |
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
| |||
114 | 112 | | |
115 | 113 | | |
116 | 114 | | |
117 | | - | |
118 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
| |||
214 | 213 | | |
215 | 214 | | |
216 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
217 | 227 | | |
218 | 228 | | |
219 | 229 | | |
| |||
225 | 235 | | |
226 | 236 | | |
227 | 237 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | 238 | | |
234 | 239 | | |
235 | 240 | | |
| |||
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
254 | | - | |
| 259 | + | |
255 | 260 | | |
256 | 261 | | |
257 | 262 | | |
258 | 263 | | |
259 | 264 | | |
260 | 265 | | |
261 | 266 | | |
262 | | - | |
| 267 | + | |
263 | 268 | | |
264 | 269 | | |
265 | 270 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
232 | 240 | | |
233 | 241 | | |
234 | 242 | | |
235 | 243 | | |
| 244 | + | |
236 | 245 | | |
237 | 246 | | |
238 | 247 | | |
| |||
0 commit comments