Repository navigation
Move Shift+Tab to the previous magic code slot instead of leaving the input - #104955
Conversation
… input Co-authored-by: Roji Philip <rojiphil@users.noreply.github.com>
|
I created this PR from an upstream branch because I don't have push access to your fork. 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❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
🤖 Android test steps verification results: I reached the shared 6-slot magic code input (Profile > Contact methods > New contact method) and confirmed digit entry and auto-advance work. I could not check the Tab, Shift+Tab, arrow key, or Backspace steps, because the Android test tool cannot send hardware key events. These are tool limits, not product failures.
The PR's Tests section is still a TODO, so these steps come from the linked issue's reproduction steps and the behavior described in the PR body. The Tab and Shift+Tab behavior still needs a manual check with a hardware keyboard on Android. |
|
@MelvinBot Merge with the latest main to resolve conflicts |
…TabPreviousSlot Co-authored-by: Roji Philip <rojiphil@users.noreply.github.com> # Conflicts: # src/components/ValidateCodeInput.tsx
|
I merged the latest The only conflict was in I couldn't run lint, typecheck, or Jest locally in this run, so CI on the new commit is the first check. |
|
@MelvinBot Merge with the latest main |
|
@MelvinBot Tidy the tests/QA sections with the following test steps. Please note that the issue is only applicable for web version and not on mobiles. Steps:
|
|
@MelvinBot Please mark the PR as ready for review |
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp104955-android-hybrid-001.mp4Android: mWeb Chrome104955-mweb-chrome-001.mp4iOS: HybridApp104955-ios-hybrid-001.mp4iOS: mWeb Safari104955-mweb-safari-001.mp4MacOS: Chrome / Safari104955-web-chrome-001.mp4 |
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. |
|
@MelvinBot Please tick the boxes in the PR Author Checklist section as I have already verified these in PR Reviewer Checklist as a co-author |
|
@MelvinBot Address the comment at #104955 (comment) |
rojiphil
left a comment
There was a problem hiding this comment.
@NikkiWines Changes LGTM and works well too.
Approving for your review. Thanks
| } | ||
|
|
||
| event.preventDefault(); | ||
| event.stopPropagation(); |
There was a problem hiding this comment.
When someone clicks the code field and then uses Tab to move between digits, the app doesn’t register that they’ve switched to keyboard navigation. This can affect where focus goes on the next screen. Can we make sure the app registers the Tab press before stopping the event?
There was a problem hiding this comment.
Yeah. A click clears hadTabNavigation, and stopPropagation() on the window listener then hides the Tab from the document listener in hadTabNavigation.ts, so the next screen does not treat this as keyboard navigation.
The listener has to stay on window, because focus-trap registers on document in componentDidMount. @MelvinBot Let us implement to mark tab navigation before stopping the event.
There was a problem hiding this comment.
🤖 Web test steps verification results: ❌ fail
Pushed 72dc821f: intercepted Tab presses now mark keyboard navigation before stopping propagation, while retaining the window listener. Browser verification was blocked by a blank page—not a demonstrated regression.
| Step | Status |
|---|---|
Middle-slot Tab/Shift+Tab, boundary exit, and next-screen keyboard focusCould not verify because the magic-code input was unavailable.![]() Automated checks passed: all 9 component tests, including two new regression cases; typecheck; targeted lint, spelling, React Compiler, and Storybook smoke test. Full Jest timed out. Change-discovery checks lacked a merge base; formatting verification was blocked. |
❌ |
|
@MelvinBot Merge with the latest main |
|
I couldn’t complete the merge. The shallow checkout lacks shared history with |
Co-authored-by: Roji Philip <rojiphil@users.noreply.github.com>
|
@rojiphil @NikkiWines One of you needs to 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] |
|
@MelvinBot Please fix the |
Co-authored-by: Roji Philip <rojiphil@users.noreply.github.com>
There was a problem hiding this comment.
@NikkiWines Changes for #104955 (comment) LGTM.
Approving for your review.
104955-web-chrome-003.mp4
|
Hi! We are aware Melvin tester runs are failing. Please if you could update this branch to latest main and re-run it - this should resolve the issue. If not, reach out to me directly. Thanks for your patience! |
|
🚧 NikkiWines has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/NikkiWines in version: 9.5.36-0 🚀
|
|
No FullStory changes needed — this PR only fixes Tab/Shift+Tab focus navigation in the existing magic-code input and adds regression tests, without introducing new UI, screens, user properties, or sensitive content. |
|
No help site update needed — this PR restores expected Tab and Shift+Tab navigation within the security code input on web; it adds no new workflow and makes no existing article inaccurate. |
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.36-0 🚀
Bundle Size Analysis (Sentry): |





Explanation of Change
On web, Shift+Tab from a middle magic code slot now moves to the previous slot. Before this change, focus jumped to the footer language selector.
Why it broke:
focus-traplistens forkeydownondocumentin the capture phase. The magic code input is one hiddenTextInputbehind all 6 slots, and it is the first tabbable node in the screen's trap. Sofocus-trapwraps Shift+Tab to the last tabbable node before React'sonKeyPressruns. By thenonBlurhas already clearedfocusedIndex, and the Tab branch inonKeyPressdoes nothing.What changed in
ValidateCodeInput.tsx:keydownlistener onwindowin the capture phase. It runs beforefocus-trap'sdocumentlistener. It is guarded bytypeof document === 'undefined', like the paste listener.Tabor Shift+Tab (no Alt, Ctrl, or Meta), and only while this hidden input is focused. It checksisFocused(), and on web it also requiresdocument.activeElementto be the input.0 .. maxLength - 1, it callspreventDefault()andstopPropagation(), updates afocusedIndexRef, and then callssetInputAndIndex.preventDefault()alone is not enough, becausefocus-trap'scheckKeyNavignoresdefaultPrevented. The ref keeps key repeat from applying the same move twice before React re-renders.onKeyPressTab branch is unchanged, so hardware-keyboard Tab on iOS and Android still works. On web, in-range Tab never reaches it.isFocused()check moved into a smallisInputFocusedhelper, so both listeners use it.Tests: I added
tests/ui/ValidateCodeInputTest.tsx. It dispatches nativeKeyboardEvents that pass through thewindowcapture phase, plus adocumentcapture listener that stands in forfocus-trap. The events are dispatched ondocument.bodyinstead ofwindow: an event dispatched onwindownever reachesdocument, so the test could not show thatfocus-trapis skipped. The tests cover:enter digit N of 6announcement.preventDefaultat slot 1 and at the last slot.The in-range and key-repeat tests fail on
mainand pass with this change.AI tests run locally: the new test passed (7 of 7).
npm run typecheck,npm run lint-changed(my files),npm run spell-changed, the React Compiler compliance check, andoxfmtalso passed. The Android emulator was unreachable during this run, so I have no device verification yet.Fixed Issues
$ #104839
PROPOSAL: #104839 (comment)
Tests
Web only. This issue does not apply to mobile platforms.
Offline tests
QA Steps
Web only. This issue does not apply to mobile platforms.
Follow steps 1–10 in the Tests section on the web staging environment.
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