Repository navigation
fix(useKeyboardMode): ignore keydown events without a key - #725
Merged
Merged
Conversation
Browsers and password managers dispatch plain keydown events without e.key when autofilling fields, which made isEditing throw on e.key.length. Fixes #724 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKGZMmRZEJSSo6479X5r6q
size-limit report 📦
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The global
keydownlistener of the keyboard mode provider threwTypeError: Cannot read properties of undefined (reading 'length')when akeydownevent withoutkeyreached a focused input, textarea or contenteditable. Browsers and password managers send these plainEvents when they autofill fields, so every autofill ended up in error trackers.handleKeyDownnow returns early whene.keyisn't a string, the same guarduseSingletonHotkeysalready has. An event that isn't a real key press doesn't turn keyboard mode on, including when it isn't dispatched on an editable element.new Event("keydown")on an input and on the body, then checks that no error reacheswindowand thatdata-rs-keyboardstays off. It fails without the fix with the exact error from the issue.afterEachthat resetsdata-rs-keyboardon<html>, since the existingbasetest leaves keyboard mode on.Related Issue
Fixes #724
Screenshots / Recordings
No visual changes.
Notes for Reviewers
The issue suggested
e.key?.length === 1inisEditing. That stops the error but would still turn keyboard mode on for synthetic events sent outside editable fields, so this PR returns early instead.Generated by Claude Code