You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mobile): end a keyboard hold whose release the phone bar never hears - #52769
On a phone with a hardware keyboard, holding Space on the toolbar's ⌫ or arrow keys could keep deleting or scrolling history after you let go. Now the key stops as soon as you release it, even if focus moved away first.
Files
Added
Deleted
Net
Test
2
$\color{#1a7f37}{\Huge{\mathbf{+}}}$606
$\color{#cf222e}{\Huge{\mathbf{−}}}$23
$\color{#1a7f37}{\Huge{\mathbf{+}}}$583
Prod
4
$\color{#1a7f37}{\Huge{\mathbf{+}}}$348
$\color{#cf222e}{\Huge{\mathbf{−}}}$26
$\color{#1a7f37}{\Huge{\mathbf{+}}}$322
What Changed
Since #52645 the phone bar's ⌫ ↑ ↓ are buttons, so a hardware Space presses them and holding it repeats. react-native-web only counts a Space release that comes up on a button. If focus left the key before Space came up, the press never ended and the key kept sending to the terminal. A window blur lost the release of Space or Enter on every key row (phone bar, ⋯ sheet, tablet row).
A held keyboard press is now tracked per key:
If its key comes up anywhere else, the hold ends there.
If the held key loses focus or the window blurs, the hold is abandoned: the repeat stops and never resumes. That same physical press's auto-repeats and release send nothing.
Either way react-native-web is shown a release on the key, so it looks released and the next press is a fresh one. That release never sends a key itself. If it ends another key's live touch press, that touch hold stops at its own finger lift.
A keyboard hold only stops the session's repeat while it is the latest hold, so it never cuts a touch hold in the bar or the ⋯ sheet.
Touch presses, repeat timing, layout and which keys Space and Enter activate are unchanged.
Why
Patching react-native-web or reverting the buttons would be broader or undo #52645's Space and assistive-tech support. Cancelling only on window blur in the session would miss the main case, where focus moves before Space comes up.
Linked Issue
No GitHub issue. This fixes a regression from #52645.
Visual Proof
N/A for layout: nothing looks different. This is an interaction fix, so the evidence is the write counts below from a seeded page with trusted keyboard input.
Testing
Regression tests in MobileSessionAccessoryKeys.web-keyboard.test.tsx run real react-native-web in happy-dom with the real repeat timer. They cover:
focus leaving the key, a window blur, and the release coming up elsewhere (phone bar, row and sheet);
fresh taps and holds afterwards;
no resume or send from the lost press's auto-repeats or release;
touch holds and a ⋯ sheet hold surviving keyboard releases, including a touch hold that a recovery release ends early;
no write from the recovery release on a row or sheet key that an assistive click already used;
field typing left alone, unmount, and the pressed look clearing.
20 of them fail on main. Each new listener or branch was removed in turn to confirm its test goes red.
pnpm check:changed and the mobile typecheck (app and tests) pass locally.
One native-renderer test checks that an ↑ hold survives a rerender while ⌫ sits in ⋯.
Seeded page in headless Chromium, trusted keyboard input:
Scenario
Writes
Space tap
1
Enter with 2 auto-repeats
1
Space held, focus moved to a field
none from then on
Fresh tap after that
1
Fresh hold after that
repeats, then stops on release
Focus back on the key, old Space released or Enter auto-repeating
0, with no native click
Tab away mid-hold
0
Tablet row Enter recovery
1
Unmount mid-hold
0
Not covered: a real window blur (headless Chromium does not produce one, so blur is unit-tested only), and physical iOS/Android WebViews with hardware keyboards.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None measurable: work happens only while a key is held from a hardware keyboard. Each such press adds at most four event listeners, removed when it ends. A press whose release was lost keeps two document listeners until that key's next keyup or keydown. A touch hold ended early by a recovery release keeps six listeners until its finger lifts. There is no work per repeat tick, no polling, I/O or caching. The phone bar and its sheet are the only two rows mounted together.
Risk
Level: Low. The riskiest part is the release shown to react-native-web after a lost press. If it misbehaved, a key could need a second press, or a touch hold could stop early. It is confined to the terminal key rows on the mobile page build; the native app has no DOM and is untouched. Back out with a plain revert.
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
A hardware Space held on a phone bar ⌫ or arrow kept repeating once focus left
the key before Space came up: react-native-web only takes a Space release on a
button, so the press never ended. A window blur lost the release of Space or
Enter on every key row.
The hold now also ends when its key comes up elsewhere, and is abandoned when
its key loses focus or the window blurs. The repeat stops, the rest of that
press sends nothing, and react-native-web is shown a release on the key, so the
next press is fresh. A keyboard hold only stops the session's repeat while it
is the latest hold, so it never cuts a touch hold in the bar or its sheet.
…touch hold
The release shown to react-native-web after a lost keyboard hold reached the
tablet row and sheet keys' onPress. Once an assistive click had used up that
hold's prepared press, the release sent one more key. The key is now held as a
keyboard press through the reset, so that onPress sends nothing.
The same release can end another key's live touch press through a listener an
earlier keyboard press left on it. That press's finger lift then goes unheard,
so its hold now ends at the lift instead of at once.
No actionable comments were generated in the recent review.
Walkthrough
The change adds a hook that tracks keyboard holds, repeat ownership, and recovery from lost web key releases. Accessory-key events use this coordinator to manage repeat cancellation and touch disarming. The keyboard-press hook memoizes its returned object. Tests cover keyboard and touch hold interactions, recovery scenarios, and repeat persistence across rerenders.
Merge Risk: Low · up to 4280c
This fixes hardware-keyboard Space holds that kept deleting or scrolling after the key was released elsewhere. Two narrow edge cases remain: a held Space can still act on a different key the focus has moved to, and a touch on the same key can lift the guard early. Neither is likely to affect normal use, and the change is easy to revert, so it can merge with awareness of these follow-ups.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: a fix in the mobile app that ends a keyboard hold when the phone bar never receives the release event. It follows a conventional commit format and is specific to the c…
Description check
The description follows the template well. It includes ELI5, What Changed, Why, Visual Proof (N/A with reason), Testing with checkboxes, Performance, Risk with level and back-out plan, and Checklist. …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: a fix in the mobile app that ends a keyboard hold when the phone bar never receives the release event. It follows a conventional commit format and is specific to the changeset, which adds per-key keyboard hold tracking and recovery on focus loss, window blur, or release elsewhere.
Full details: Description check
Explanation
The description follows the template well. It includes ELI5, What Changed, Why, Visual Proof (N/A with reason), Testing with checkboxes, Performance, Risk with level and back-out plan, and Checklist. The Linked Issue section states there is no GitHub issue and links the regression to #52645, which the template requires for outside contributors. The author is a maintainer, so the template allows that. The AI Disclosure and Review sections are empty, and the Performance line is completed with reasoning. These are minor gaps.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
When the release shown to react-native-web after a lost keyboard hold ended
another key's live touch press, that hold stopped at the first touch or mouse
lift anywhere, so a second finger lifting elsewhere cut it short. The press-in
now records the finger (or mouse) the touch began with, and the hold ends only
when that contact is gone from the page's touches, the mouse comes up, or the
window blurs. A newer hold is left alone.
… touch
react-native-web folds touch identifiers (101 and 121 both become 1), so
matching the owning finger by identifier let a finger elsewhere keep a
reset-ended hold alive after its own finger lifted. The hold now ends as
react-native-web ends a touch press: when no remaining touch is on the key,
or the mouse comes up. A finger elsewhere still leaves it running.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
On a phone with a hardware keyboard, holding Space on the toolbar's ⌫ or arrow keys could keep deleting or scrolling history after you let go. Now the key stops as soon as you release it, even if focus moved away first.
What Changed
Since #52645 the phone bar's ⌫ ↑ ↓ are buttons, so a hardware Space presses them and holding it repeats. react-native-web only counts a Space release that comes up on a button. If focus left the key before Space came up, the press never ended and the key kept sending to the terminal. A window blur lost the release of Space or Enter on every key row (phone bar, ⋯ sheet, tablet row).
A held keyboard press is now tracked per key:
Touch presses, repeat timing, layout and which keys Space and Enter activate are unchanged.
Why
Patching react-native-web or reverting the buttons would be broader or undo #52645's Space and assistive-tech support. Cancelling only on window blur in the session would miss the main case, where focus moves before Space comes up.
Linked Issue
No GitHub issue. This fixes a regression from #52645.
Visual Proof
N/A for layout: nothing looks different. This is an interaction fix, so the evidence is the write counts below from a seeded page with trusted keyboard input.
Testing
Regression tests in
MobileSessionAccessoryKeys.web-keyboard.test.tsxrun real react-native-web in happy-dom with the real repeat timer. They cover:20 of them fail on main. Each new listener or branch was removed in turn to confirm its test goes red.
pnpm check:changedand the mobile typecheck (app and tests) pass locally.One native-renderer test checks that an ↑ hold survives a rerender while ⌫ sits in ⋯.
Seeded page in headless Chromium, trusted keyboard input:
Not covered: a real window blur (headless Chromium does not produce one, so blur is unit-tested only), and physical iOS/Android WebViews with hardware keyboards.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Performance
None measurable: work happens only while a key is held from a hardware keyboard. Each such press adds at most four event listeners, removed when it ends. A press whose release was lost keeps two document listeners until that key's next keyup or keydown. A touch hold ended early by a recovery release keeps six listeners until its finger lifts. There is no work per repeat tick, no polling, I/O or caching. The phone bar and its sheet are the only two rows mounted together.
Risk
Level: Low. The riskiest part is the release shown to react-native-web after a lost press. If it misbehaved, a key could need a second press, or a touch hold could stop early. It is confined to the terminal key rows on the mobile page build; the native app has no DOM and is untouched. Back out with a plain revert.
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)