Skip to content

Conversation

@runway-github
Copy link
Contributor

@runway-github runway-github bot commented Nov 18, 2025

Description

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

CHANGELOG entry: Fixed OTP input freezing issues on Card email and phone
verification screens

Related issues

Fixes:

Manual testing steps

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

Before

After

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.

Note

Integrates useBlurOnFulfill and platform-specific autoComplete for OTP fields, fixes resend cooldown timing, and updates tests/mocks accordingly.

  • Card OTP flows (CardAuthentication, ConfirmEmail, ConfirmPhoneNumber):
    • Add useBlurOnFulfill for proper focus/blur handling and use its ref for CodeField.
    • Update focus effects and dependency arrays; remove manual useRef usage.
    • Use platform-specific autoComplete (android: sms-otp, default: one-time-code).
    • Keep auto-submit on full code entry; maintain useClearByFocusCell.
  • Resend logic:
    • ConfirmPhoneNumber: start cooldown only after successful resend.
    • ConfirmEmail: store returned contactVerificationId from resend.
  • Tests:
    • Update mocks for react-native-confirmation-code-field to include useBlurOnFulfill and align with ref changes.

Written by Cursor Bugbot for commit 9b259a1. This will update automatically on new commits. Configure here.

9f9609f

… 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 -->
@runway-github runway-github bot requested a review from a team as a code owner November 18, 2025 23:32
@github-actions
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.

@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Nov 18, 2025
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeCard
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

The changes affect Card authentication and onboarding flows in MetaMask Mobile. All 6 changed files are related to the Card feature:

  1. Component Files (3):

    • CardAuthentication.tsx: Handles login with OTP authentication flow
    • ConfirmEmail.tsx: Email verification during onboarding
    • ConfirmPhoneNumber.tsx: Phone number verification during onboarding
  2. Test Files (3):

    • Corresponding .test.tsx files for each component

Analysis:
From reading the files, these components handle critical Card functionality including:

  • Two-factor authentication with OTP codes
  • Email and phone number verification during onboarding
  • Auto-submit functionality when verification codes are complete
  • Resend code functionality with cooldown timers
  • Navigation between different onboarding steps
  • Integration with Card SDK and verification hooks

Without git diffs available, I cannot determine the exact nature of changes, but these files contain:

  • Complex state management for OTP flows
  • Auto-submission logic
  • Timer-based functionality (cooldown)
  • Navigation logic
  • Error handling

The test files are comprehensive with 1300+ lines each, indicating these are well-tested components.

Risk Assessment: Medium

  • These are Card-specific flows (authentication/onboarding)
  • Changes affect critical user authentication paths
  • Comprehensive test coverage exists but functional changes need E2E validation
  • Card feature has dedicated E2E tests (card-button.spec.ts, etc.)

Tag Selection:

  • SmokeCard: Appropriate tag for Card authentication and onboarding flows

View GitHub Actions results

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
36.4% Duplication on New Code (required ≤ 10%)

See analysis details on SonarQube Cloud

@joaoloureirop joaoloureirop added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Nov 19, 2025
@joaoloureirop joaoloureirop merged commit a40aa3f into release/7.60.0 Nov 19, 2025
159 of 162 checks passed
@joaoloureirop joaoloureirop deleted the runway-cherry-pick-7.60.0-1763508756 branch November 19, 2025 14:27
@github-actions github-actions bot locked and limited conversation to collaborators Nov 19, 2025
@metamaskbot metamaskbot added the release-7.60.0 Issue or pull request that will be included in release 7.60.0 label Nov 19, 2025
@metamaskbot
Copy link
Collaborator

No release label on PR. Adding release label release-7.60.0 on PR, as PR was cherry-picked in branch 7.60.0.

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

Labels

release-7.60.0 Issue or pull request that will be included in release 7.60.0 size-M skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants