Skip to content

[codex] Fix keyboard event detection to use logical keys - #1080

Draft
wanxiankai wants to merge 1 commit into
reactjs:masterfrom
wanxiankai:fix/keyboard-event-key
Draft

wanxiankai wants to merge 1 commit into
reactjs:masterfrom
wanxiankai:fix/keyboard-event-key

Conversation

@wanxiankai

Copy link
Copy Markdown

Acceptance Checklist:

  • Tests
  • Documentation and examples (not needed; no public API changes)

Fixes #1030.

What changed

  • Detect Tab and Escape with KeyboardEvent.key, which represents the logical key value.
  • Keep the existing keyCode fallback for older React/IE environments.
  • Update modern keyboard-event tests to exercise key and add a regression test for a physical Escape code that represents a different logical key.

Why

KeyboardEvent.code identifies the physical key location. Some input methods can therefore emit code: "Escape" while key is a non-Escape value such as "Process". The previous check treated that event as Escape and closed the modal unexpectedly while the user was inserting text or emoji.

Validation

  • Browser test suite: 86 passed, 0 failed, 0 skipped
  • Regression test: should not close when Escape code represents another logical key
  • npm run lint
  • git diff --check

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant