Repository navigation
Replace useDelayedAutoFocus with useAutoFocusInput in sub-step forms - #105572
Conversation
The fixed 300 ms focus timer could fire before the screen push transition finished. On iOS the input then lost focus, which marked the empty field as touched and showed a 'This field is required' error. useAutoFocusInput waits for the transition to end before focusing. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
I created this PR from an upstream branch because I can't push to a fork for you. If you want to take ownership of this branch and push updates, run: Then you can close this PR and open a new one from your fork. |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@codex review |
|
@MelvinBot review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
I found no high-severity regressions. Every sub-step still gets autofocus. Each Next, Back, or Edit is a real screen push, and The new hook changes behavior in four small ways:
Not verified in the app. These findings come from reading the code. On Web, every path to these screens is blocked by the "Validate your account" code screen (see my earlier comment). The bank account flow tests (USDVerifiedBankAccountFlowPageTest.tsx) don't check focus. Worth checking on iOS: the Company name step mounts after the loading redirect. Its focus may come from the 1-second fallback rather than Ruled out
|
|
@MelvinBot add QA Steps below and mark this PR ready for review
|
|
I added your 8 QA steps to the QA Steps section and marked this PR ready for review. The Tests section still has its TODO placeholder. The PR Author Checklist and Screenshots/Videos sections are also still empty. You may need to fill those in before the PR Author Checklist check passes. |
|
@mkhutornyi Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.mp4Android: mWeb ChromeiOS: HybridAppios.MP4ios.mp4iOS: mWeb SafariMacOS: Chrome / Safariweb1.movweb2.mov |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #104049 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
NicolasBonet
left a comment
There was a problem hiding this comment.
@mkhutornyi please fill all the PR description gaps like QA, offline steps, checklist
We can skip Melvin's author checklist as per #104228 |
|
@MelvinBot add missing Tests, Offline steps |
|
I added the Tests and Offline tests sections to the PR description.
I didn't run these steps. Please check them on iOS, where the bug happens. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 NicolasBonet has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/NicolasBonet in version: 9.5.28-4 🚀
|
|
No help site update needed. This PR fixes an iOS autofocus timing bug that showed "This field is required" too early on bank account sub-steps; it changes no feature, label, or workflow that a help article describes. |
|
🚀 Deployed to staging by https://github.com/NicolasBonet in version: 9.5.30-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.5.30-0 🚀
Bundle Size Analysis (Sentry): |



Explanation of Change
The app had two ways to delay input autofocus.
SingleFieldStepandRegistrationNumberStepuseduseDelayedAutoFocus, which focused the input after a fixed 300 ms timer. Every other screen usesuseAutoFocusInput, which waits for the screen transition to end (transitionEndandTransitionTracker.runAfterTransitions).On iOS, the fixed timer could focus the input while the push transition to the next step was still running. The input then lost focus,
FormProvidertreated that blur as a user action, and the empty field showed "This field is required" before the user typed anything. For example, this happened on the Company name step after Onfido.This PR:
useAutoFocusInputinSingleFieldStepandRegistrationNumberStepwhenshouldDelayAutoFocusis set. The input getsinputCallbackRefonly in that case, matchingNonUSD/SignerInfo/EnterEmail.tsx.useDelayedAutoFocus, which has no other callers.Every step that passes
shouldDelayAutoFocusgets the fix, not just the Company name step. Landscape mode still skips autofocus, becauseuseAutoFocusInputalready checksisInLandscapeMode.AI Tests
npm run typechecknpm run lint-changednpm run react-compiler-compliance-check checkon both changed componentsnpm test -- --findRelatedTestson the changed files: 100 suites and 1,211 tests passed, includingUSDVerifiedBankAccountFlowPageTestandAddPersonalBankAccountPageTestoxfmt --check, the fullnpm run lintandnpm testsuites, and the Storybook smoke test. The edits only remove lines and swap one import in the same sort position.Fixed Issues
$ #104049
PROPOSAL: #104049 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari