Skip to content

fix(useKeyboardMode): ignore keydown events without a key - #725

Merged
blvdmitry merged 1 commit into
mainfrom
claude/relaxed-archimedes-o2nkjh
Nov 22, 2026
Merged

blvdmitry merged 1 commit into
mainfrom
claude/relaxed-archimedes-o2nkjh

Conversation

@blvdmitry

Copy link
Copy Markdown
Contributor

Summary

The global keydown listener of the keyboard mode provider threw TypeError: Cannot read properties of undefined (reading 'length') when a keydown event without key reached a focused input, textarea or contenteditable. Browsers and password managers send these plain Events when they autofill fields, so every autofill ended up in error trackers.

handleKeyDown now returns early when e.key isn't a string, the same guard useSingletonHotkeys already 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.

  • Regression browser test: dispatches new Event("keydown") on an input and on the body, then checks that no error reaches window and that data-rs-keyboard stays off. It fails without the fix with the exact error from the issue.
  • Added an afterEach that resets data-rs-keyboard on <html>, since the existing base test leaves keyboard mode on.
  • Patch changeset.

Related Issue

Fixes #724

Screenshots / Recordings

No visual changes.

Notes for Reviewers

The issue suggested e.key?.length === 1 in isEditing. 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

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
@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Library / JS 54.06 KB (+0.1% 🔺) 1.1 s (+0.1% 🔺) 0 ms (+100% 🔺) 1.1 s
Library / CSS 24.88 KB (0%) 498 ms (0%) 0 ms (+100% 🔺) 498 ms
Theming / JS 7.8 KB (0%) 156 ms (0%) 58 ms (-8.91% 🔽) 214 ms
Theming with a default theme definition / JS 8.68 KB (0%) 174 ms (0%) 127 ms (+18.63% 🔺) 301 ms

@blvdmitry
blvdmitry merged commit 60f82ca into main Nov 22, 2026
11 checks passed
@blvdmitry
blvdmitry deleted the claude/relaxed-archimedes-o2nkjh branch November 22, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard mode: keydown listener throws when the event has no key (browser autofill)

2 participants