Skip to content

fix(useHotkeys): alt combos fire on macOS, where Option rewrites the typed character - #12213

Merged
cixzhang merged 10 commits into
mainfrom
lane2/hotkeys-alt-macos
Nov 20, 2026
Merged

cixzhang merged 10 commits into
mainfrom
lane2/hotkeys-alt-macos

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Owner: fix lane 2. Land path: draft → Specs check → CodeBunny → merge queue.

Overlap checked: #10095 (it scopes page shortcuts to the topmost layer in a record; it does not touch useHotkeys.ts's key matching)

User impact

An app that registers an Option shortcut with useHotkeys, such as 'alt+a' or 'alt+1', gets nothing on macOS: the shortcut never fires. Option changes the character a key types there (Option+A types "å", Option+1 types "¡", and Option+N, E, U, I and backtick are dead keys), and the hook compared only event.key. Linux and Windows work, because Alt does not change the character. Apps had to write their own matcher on event.code. Now the documented combo fires on macOS, as it does on Windows and Linux; on iPadOS and iOS the hook applies the same rule to a hardware keyboard.

Fix

On Apple platforms only (macOS; on iPadOS and iOS the hook applies the same rule to a hardware keyboard, which uses the same layouts, without a device check), in matchesCombo, when the combo names alt and event.key did not match, the final key also matches by its US key position (event.code: Key<X>, Digit<N>, and the US punctuation codes). It does so only when Option rewrote the character: the key is a dead key or a single non-ASCII character. So:

  • On macOS the position is the US one, on every layout: on an AZERTY Mac, Option plus the key labeled A fires 'alt+q'. A key whose Option character is plain ASCII still matches by that character.
  • Shifted punctuation is named with shift: 'alt+shift+/' fires on Option+Shift+/ ("¿"); 'alt+?' does not.
  • Windows, Linux, ChromeOS and Android are unchanged. Alt changes no character there, and AltGr (reported as Ctrl+Alt) types letters such as "ą" that must not fire a ctrl+alt shortcut.
  • A combo that names no alt never matches by position, and shortcuts stay silent in text fields unless allowInInputs is set.

The Hotkey.keys comment, useHotkeys.doc.mjs and the Changeset state the rule.

Records

architecture:react-component-runtime gains INV20, which states how a useHotkeys combo matches: layout-following by default; on macOS, when Option types a dead key or a non-ASCII character, an alt combo with a letter, digit, punctuation or space key matches the US key position; a plain-ASCII Option character matches as typed; macOS shifted punctuation is named with shift; Windows and Linux follow the layout only, so an AltGr letter never fires a shortcut; editable targets follow allowInInputs. Its verification row names the 15 new cases in useHotkeys.test.ts, the Safari real-device check, and the open Chrome-on-macOS gap. The record's scope sentence now names INV20 as the one user-facing rule it owns, because no component owns shortcut matching. The macOS rule is the one the platform forces: the browser reports only the key's position synchronously. The exact-Shift question (Shift is ignored when a combo does not name it) is separate and not changed here.

Writing rubric results

Record: docs/architecture/react-component-runtime.md (INV20 and its verification row).

  • R1 narration: none; present tense, what the hook does.
  • R2 research: none.
  • R3 evidence: the verification row names the 15 new cases in useHotkeys.test.ts, the Safari real-device check, and what fails.
  • R4 rejected alternatives: none in the record.
  • R5 change references: none.
  • R6 open questions: none.
  • R7 project status: one evidence-gap line in the verification row (Chrome on macOS and an iPadOS hardware keyboard have no real-device check), in the record's gap form.

Evidence

Red first: on main, the new cases for Option+A (key: 'å', code: 'KeyA'), the dead keys N, E, U, I and backtick, and Option+1 fail. The Windows AltGr case (Polish "ą" with Ctrl+Alt must not fire ctrl+alt+a or cancel the letter) fails on this pull request's first head and passes here. All 28 cases pass, 15 of them new.

Each guard has a case that fails without it: removing the plain-ASCII check fails a German Mac's Option+L ("@") with only 'alt+l' registered; removing the alt check fails an unmodified "é" on Digit2 with only '2' registered; removing the dead-key exception to the input-method guard fails the Option dead keys.

Real device, Safari on macOS, checked at the final head 585205b (Storybook built from this head). macOS 27.0 (26A428), U.S. layout (com.apple.keylayout.US), Safari 27.0 (22625.1.29.11.27), with real OS-level key events (Option down, E down and up, Option up). On the page body the dead key arrives as key: 'Dead', code: 'KeyE', key code 69, altKey: true, not composing, and 'alt+e' fires. In a text field the same keys compose: compositionstart, then the dead key with key code 229 and isComposing: true, then E. The field holds "é", and the shortcut does not fire. The same steps at 62ad602 gave the same result. A unit case pins Safari's body event (key code 69).

Other browsers. A browser may report an Option dead key with key code 229 outside composition. The input-method guard dropped key code 229 before matching, so a dead key with Option that is not composing now passes it. A key an input method composes ('Process', or isComposing) is still ignored, with a test. Evidence gaps: Chrome on macOS, and an iPadOS hardware keyboard, have no real-device check; the record's verification row states both.

Scope

Components: useHotkeys

  • One fix.
  • Test-backed, red first.
  • Public text contains no internal context.

…typed character

When the combo names alt and Option has rewritten event.key (a non-ASCII character or a dead key), the final key also matches by its physical position (event.code). A key that typed a plain character keeps layout-following event.key matching, and the text-field rule is unchanged.
@cixzhang cixzhang added the lane:2 Astryx fix-loop lane 2 owns this label Nov 17, 2026
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 20, 2026 3:53am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@astracat-bot

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 20, 2026, 4:19 PM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 5b82d66

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · c229a9d

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/core 7.85 MB packed (+1.5 kB); no new dependencies.

Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

…he US position and alt+shift punctuation

On other platforms Alt changes no character, and AltGr (reported as Ctrl+Alt) types letters that must not fire shortcuts, so only macOS uses the position. The fallback follows the US key position on every Mac layout (an AZERTY Mac fires alt+q from the key labeled A); the changeset and docs say so, and shifted punctuation is named as alt+shift+<key>. Tests pin the AZERTY Mac result, alt+shift+/ and a Polish AltGr letter on Windows (red first).
@cixzhang

cixzhang commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

(Posted by Cindy's agent. This is the agent's records ruling on the matching rule this review asked about, not a decision Cindy made.) Before this change an alt combo never fired on macOS, because Option rewrites event.key; the documented combo is the promise, so restoring it is a defect repair. The rule chosen: on macOS only, when the combo names alt and Option rewrote the final key, that key matches by its US key position (event.code), because the browser offers no synchronous keyboard-layout map. On a non-US Mac layout an Option shortcut therefore follows key position (AZERTY: Option plus the key labeled A fires alt+q), and shifted punctuation is named with shift (alt+shift+/). Windows and Linux keep layout-following matching, so AltGr text entry is never read as a shortcut. Every other combo and every plain-character key are unchanged. The public documentation states this rule.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec ab8dfbd

…aracters match by character

Option+Space types a no-break space, so the space key maps to Space for the US-position match. The docs, JSDoc and Changeset state the exact rule: on macOS the US position applies when Option types a dead key or a non-ASCII character; a plain ASCII character matches as typed (a German Mac's Option+L types @). Shifted-punctuation guidance is scoped to macOS.
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec c0d487a

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the macOS fallback works for the cases the tests cover, but the new record clause conflicts with its record's scope, the tests its verification row counts do not all catch the rule breaking, and the dead-key claim has no real-browser check.

  • The new INV20 puts a user-facing rule (which key press fires a shortcut) in the React runtime record, whose unchanged System model says it owns only the shared React lifecycle boundary and leaves user-facing outcomes to component and family contracts, so either amend that sentence to name INV20 or move INV20 to a record that owns user-facing behavior, such as beside the Kbd record's modifier glyphs.
  • INV20's verification row counts the plain-ASCII and combo-without-alt cases, but deleting the isRewrittenByOption or wantsAlt guard in matchesCombo leaves all 24 cases green, because those tests register the character combo first or press Option on a combo without alt; register 'alt+l' alone for the German Option+L case and '2' alone for an unmodified 'é' on Digit2, and say the row names the 11 new cases.
  • Miss: the release note, docs and INV20 promise that Option dead keys (N, E, U, I and backtick) fire alt combos, but the matcher runs after the IME guard that drops keyCode 229, so please state in the description what Chrome on macOS does for Option+E with 'alt+e' registered, and narrow the claim or let that keydown through if it is dropped.

The amended record needs a fresh /approve-spec <full head SHA> from an engineering owner at its new head, and the author may post it as one. Separately, the comment above the new branch in matchesCombo could drop the sentence that restates its condition.

Claims and files checked

Review mode: same-head; reason: none

  • Claim: Option shortcuts such as 'alt+a' and 'alt+1' never fired on macOS because Option rewrites the typed character and the hook compared only event.key: verified (the base compares only event.key; six new cases fail there).
  • Claim: Linux and Windows already worked because Alt does not change the character: verified for the hook (the non-Apple path is unchanged).
  • Claim: the documented combo now fires on every platform: verified in unit tests for non-dead keys; unproven in a real macOS browser for dead keys.
  • Claim: on macOS only, an alt combo whose event.key misses matches the final key's US position, only when Option typed a dead key or a non-ASCII character: verified (useHotkeys.ts:170-179).
  • Claim: on an AZERTY Mac, Option plus the key labeled A fires 'alt+q': verified (test).
  • Claim: a key whose Option character is plain ASCII still matches by that character: verified in code; no test fails when it breaks.
  • Claim: 'alt+shift+/' fires on Option+Shift+/ and 'alt+?' does not: verified on macOS (? has no US key code in the map).
  • Claim: other platforms are unchanged, and an AltGr letter does not fire a ctrl+alt shortcut: verified (platform gate; test fails without it).
  • Claim: a combo without alt never matches by position, and text fields stay silent unless allowInInputs is set: verified in code; the no-alt test never reaches the position branch.
  • Claim: the Hotkey.keys comment, the hook's doc file and the changeset state the rule: verified.
  • Claim: the runtime record gains a clause stating the rule, with a verification row pointing at the test file: verified.
  • Claim: the runtime record already lists the hook, so it owns the rule: false (it names the hook only as a latest-value-ref gap, and its scope leaves user-facing outcomes to component and family contracts).
  • Claim: the browser reports only the key's position synchronously: consistent (the change uses no layout map).
  • Claim: the exact-Shift behavior is unchanged: verified.
  • Claim: rubric R1, R2, R4 to R7 find no narration, research, rejected alternatives, change references, open questions or status in the record clause: verified.
  • Claim: rubric R3, the verification row names the 24 cases: false (it names the 11 new cases).
  • Claim: red first on main for Option+A, the dead keys and Option+1: verified (six new cases fail on the base).
  • Claim: the AltGr case fails on the first revision and passes here: verified (it fails whenever the platform gate is absent).
  • Claim: all 24 cases pass, including Option+Space and a German Mac's Option+L: verified.
  • Claim: new cases pin the AZERTY result, 'alt+shift+/', a plain-ASCII Option character, a combo without alt and a text field: present; the plain-ASCII and no-alt cases do not fail when their rule breaks.
  • Claim: the overlapping pull request does not touch the hook's key matching: verified (it changes two record files only).
  • Changeset: 'alt+a', 'alt+1' and 'alt+space' now fire on macOS: verified (tests).
  • Changeset: Option changes the typed character and some keys are dead keys, so the combo never matched: verified.
  • Changeset: on macOS a dead key or non-ASCII character matches the key's US position on any layout, so AZERTY fires 'alt+q': verified for non-dead keys; dead keys unproven in a real macOS browser.
  • Changeset: a plain-ASCII Option character matches that character, so a German Mac fires 'alt+@': verified.
  • Changeset: on macOS, shifted punctuation is named 'alt+shift+/': verified.
  • Changeset: other platforms are unchanged, and shortcuts stay silent in text fields: verified.
  • File .changeset/hotkeys-alt-macos.md: clear apart from the dead-key claim (blocking finding 3).
  • File docs/architecture/react-component-runtime.md: blocking findings 1 and 2.
  • File packages/core/src/hooks/useHotkeys.doc.mjs: clear (the reflow changes no string; the dead-key text falls under finding 3).
  • File packages/core/src/hooks/useHotkeys.test.ts: blocking finding 2.
  • File packages/core/src/hooks/useHotkeys.ts: blocking finding 3; one non-blocking comment suggestion.
  • Changed rules since the last review (0): none.

Automated review (maintainer link)

Comment thread packages/core/src/hooks/useHotkeys.ts Resolved
Comment thread packages/core/src/hooks/useHotkeys.ts Resolved
…sts catch each guard

Chrome and Safari report an Option dead key with key code 229, which the input-method guard dropped before matching. A dead key with Option that is not composing now reaches the matcher; input-method keys (Process, or isComposing) are still ignored. The German Option+L and the unmodified AZERTY Digit2 cases now register one combo each, so removing the plain-ASCII or alt guard fails them. The runtime record's scope sentence names INV20, and its verification row names the 14 cases and the open real-browser gap.
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 62ad602

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the description's rubric results are now accurate, and the macOS fallback, its guards and the record change approved at this head hold up, but one thing remains.

  • The release note, the hook docs and INV20 promise that Option dead keys (N, E, U, I and backtick) fire alt combos, but nothing shows what Chrome and Safari on macOS actually send for that keydown, so please state in the description, for each browser, the macOS version and keyboard layout, the browser version and the result for Option+E with 'alt+e' registered, or drop dead keys from those claims and from the guard exception.

Separately, the record row's "yet" sentence can leave once the browser check exists, and the isOptionDeadKey comment could drop its first sentence; both are noted inline. Each new head needs a fresh /approve-spec <full head SHA> from an engineering owner, and the author may post it as one.

Claims and files checked

Review mode: same-head; reason: none

  • Claim: Option shortcuts such as 'alt+a' and 'alt+1' never fired on macOS because Option rewrites the typed character and the hook compared only event.key: verified (the base compares only event.key; six new cases fail with the base hook).
  • Claim: Linux and Windows already worked because Alt does not change the character: verified for the hook (the non-Apple path still compares the typed character).
  • Claim: apps had to write their own matcher on event.code: context only (no caller in the repository registers an alt combo; the block registers / and ?, the shell page meta+k and ctrl+k).
  • Claim: the documented combo now fires on every platform: verified in unit tests for non-dead keys; unproven in a real macOS browser for dead keys.
  • Claim: on macOS only, an alt combo whose event.key misses matches the final key's US position, only when Option typed a dead key or one non-ASCII character: verified (a test fails when the platform, alt or rewrite guard is removed).
  • Claim: on an AZERTY Mac, Option plus the key labeled A fires 'alt+q': verified (test).
  • Claim: a key whose Option character is plain ASCII matches only by that character: verified (the 'alt+l'-alone test fails without the guard).
  • Claim: 'alt+shift+/' fires on Option+Shift+/ and 'alt+?' does not: verified (test; ? has no US key code in the map).
  • Claim: other platforms are unchanged, and an AltGr letter does not fire a ctrl+alt shortcut: verified (the test fails without the platform gate and with the first revision's hook).
  • Claim: a combo without alt never matches by position, and text fields stay silent unless allowInInputs is set: verified (tests).
  • Claim: the Hotkey.keys comment, the hook's doc file and the changeset state the rule: verified.
  • Claim: the runtime record gains a clause stating the rule, a verification row naming the 14 new cases and the open browser gap, and a scope sentence naming the clause: verified.
  • Claim: the browser reports only the key's position synchronously: consistent (the change reads event.code only).
  • Claim: the exact-Shift behavior is unchanged: verified.
  • Claim: rubric R1, R2 and R4 to R6 find no narration, research, rejected alternatives, change references or open questions in the record change: verified.
  • Claim: rubric R3, the verification row names the 14 new cases and what fails: verified.
  • Claim: rubric R7, one evidence-gap line in the verification row: verified (the line exists; see the non-blocking note on its wording).
  • Claim: red first on main for Option+A, the dead keys and Option+1: verified (six new cases fail with the base hook).
  • Claim: the AltGr case fails on the first revision and passes here: verified.
  • Claim: all 27 cases pass, 14 of them new: verified.
  • Claim: each guard (plain ASCII, alt, the dead-key exception) has a case that fails without it: verified.
  • Claim: Chrome and Safari on macOS report an Option dead key with key code 229 and not as composing, and Firefox reports the letter's key code: unverified (no real-browser result; the description says so).
  • Claim: the guard lets a non-composing Option dead key through, an input-method key is still ignored with a test, and the jsdom cases use key code 229: verified.
  • Claim: the overlapping pull request does not touch the hook's key matching: verified (it changes two record files only).
  • Changeset: 'alt+a', 'alt+1' and 'alt+space' now fire on macOS: verified (tests).
  • Changeset: Option changes the typed character and some keys are dead keys, so the combo never matched: verified.
  • Changeset: on macOS a dead key or non-ASCII character matches the key's US position on any layout, so AZERTY fires 'alt+q': verified for non-dead keys; dead keys unproven in a real macOS browser.
  • Changeset: a plain-ASCII Option character matches that character, so a German Mac fires 'alt+@': verified.
  • Changeset: on macOS, shifted punctuation is named 'alt+shift+/': verified.
  • Changeset: other platforms are unchanged, and shortcuts stay silent in text fields: verified.
  • File .changeset/hotkeys-alt-macos.md: the dead-key claim needs browser evidence (the bullet above).
  • File docs/architecture/react-component-runtime.md: clear apart from the row's "yet" sentence (non-blocking).
  • File packages/core/src/hooks/useHotkeys.doc.mjs: clear apart from the dead-key text (the bullet above); the reflow changes no string.
  • File packages/core/src/hooks/useHotkeys.test.ts: clear (every counted case fails when its rule breaks).
  • File packages/core/src/hooks/useHotkeys.ts: the dead-key guard needs browser evidence (the bullet above); one non-blocking comment suggestion.
  • Pull request description: clear (the rubric lines are now accurate).

Automated review (maintainer link)

Comment thread packages/core/src/hooks/useHotkeys.ts Resolved
…ds the Safari real-device check

Safari 27 on macOS 27 reports an OS-level Option+E on the page body as key Dead, code KeyE, key code 69, not composing; the case pins it. The record's verification row states the Safari check and keeps Chrome on macOS as the open gap. The dead-key comment no longer says Safari uses key code 229.
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 7147e41

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec daff213

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 17, 2026
…e rule

The release note promises the combo fires on macOS, where a real device shows it. On iPadOS and iOS it states that the hook applies the same rule to a hardware keyboard, without a device check there.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 585205b

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the Apple-platform matching, its guards and INV20 (approved at this head) hold up, and the description now matches the evidence for iPadOS and iOS, but one point remains.

Blocking:

  • The Safari real-Mac check for Option+E is stated at an earlier commit, and the commits since edit useHotkeys.ts and useHotkeys.doc.mjs, which the device-evidence carry rule (spec:AST-094 DEC-31) does not cover, so please state that check (macOS and Safari versions, layout, result) at the final head.

The hook's runtime code is unchanged since the commit that was checked, so repeating the same steps is enough. The earlier comment-wording suggestions still stand and are non-blocking.

Claims and files checked

Review mode: same-head; reason: none

  • changed rules (0): none

Claims:

  • Option shortcuts such as alt+a and alt+1 never fired on a Mac because the hook compared only the typed character, while Windows and Linux worked: verified (seven new cases fail with the base hook).
  • The documented combo now fires on macOS as on Windows and Linux, and iPadOS and iOS apply the same rule to a hardware keyboard: verified in code (useHotkeys.ts:182-188; a probe fires only for iPad, iPhone and Mac platform values).
  • The key-position match applies only on Apple platforms, with no device check on iPadOS and iOS: verified (useHotkeys.ts:183).
  • It applies only when Option typed a dead key or a single non-ASCII character: verified (useHotkeys.ts:179-181, useHotkeys.test.ts:385).
  • On every layout the US position wins, so AZERTY Option plus the key labeled A fires alt+q: verified (useHotkeys.test.ts:349).
  • A plain-ASCII Option character matches only as typed, so German Option+L fires alt+@, not alt+l: verified (useHotkeys.test.ts:385, :394).
  • alt+shift+/ fires on Option+Shift+/ and alt+? does not: verified (useHotkeys.test.ts:367; ? has no position code at useHotkeys.ts:102).
  • Windows, Linux, ChromeOS and Android are unchanged, and an AltGr letter neither fires a ctrl+alt shortcut nor is cancelled: verified (useHotkeys.test.ts:412).
  • A combo without alt never matches by position, and text fields stay silent without allowInInputs: verified (useHotkeys.test.ts:403, :425).
  • The Hotkey.keys comment, the hook docs and the release note state the rule: verified.
  • INV20 states the rule, its verification row names the 15 cases, the Safari check and the open gaps, and the scope sentence names INV20: verified (react-component-runtime.md:107-111, :464-477, :706); the description's summary of INV20 names fewer platforms than the clause, which is narrower, not false.
  • Only the key position is available synchronously at keydown: consistent with the code's rationale.
  • Shift handling for combos that do not name shift is unchanged: verified (useHotkeys.ts:165-168).
  • The writing rubric results match the record: verified.
  • Red first, the Option+A, dead-key and Option+1 cases fail before the fix: verified (seven cases fail).
  • The AltGr case fails on the first commit and passes here: verified.
  • All 28 cases pass, 15 of them new: verified.
  • Each guard has a case that fails without it: verified (five guard mutations, each failing one case).
  • Safari on a real Mac fires alt+e on the page and types é in a field without firing it: stated for an earlier commit and being repeated at this head, with no result yet (finding).
  • A key an input method composes is still ignored: verified (useHotkeys.test.ts:302).
  • Chrome on macOS and an iPadOS hardware keyboard have no device check: verified as stated in the record row.
  • The overlapping pull request does not touch the hook's key matching: verified (it changes only two records).
  • Public text has no internal context: verified.
  • Release note: alt+a, alt+1 and alt+space now fire on macOS, and iPadOS and iOS apply the same rule: verified in code and tests (the Safari result is the finding above).
  • Release note: the AZERTY, German, shifted-punctuation, unchanged-platform and text-field statements: verified as above.
  • Release note: a patch bump for a fix: verified.

Files:

  • .changeset/hotkeys-alt-macos.md: clear.
  • docs/architecture/react-component-runtime.md: INV20 matches the code; the verification row's Safari check does not reach this head (finding); its failure-signal cell names fewer platforms than the clause (non-blocking).
  • packages/core/src/hooks/useHotkeys.doc.mjs: consistent with INV20; the reflow is formatting only.
  • packages/core/src/hooks/useHotkeys.test.ts: clear.
  • packages/core/src/hooks/useHotkeys.ts: matcher and guard clear; comment-wording suggestions (non-blocking).

Automated review (maintainer link)

Comment on lines +174 to +178
// On Apple platforms (macOS, and iPadOS or iOS with a hardware keyboard),
// Option changes the character a key types: Option+A types "å",
// Option+1 types "¡", and some keys are dead keys. Elsewhere Alt changes no
// character, and AltGr (Ctrl+Alt) types letters that must not fire
// shortcuts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (comment style): the first sentence runs 31 words over three topics. Suggested:

// On Apple platforms, Option changes the typed character. Option+A types "å",
// Option+1 types "¡", and some keys are dead keys. Elsewhere Alt changes no
// character. AltGr (Ctrl+Alt) types letters, and these must not fire shortcuts.

| INV18 reorder | Browser tests of a mouse drag in a reorderable List while a wheel scrolls its scroller: one checks the preview, the drop line and the drop, and one traces layout and counts the offset reads | A wheel scroll mid-drag that leaves the drop line or the preview off the pointer, a drop away from the pointer, a layout the read forces, or more than one read in a scrolled frame |
| INV18 (after layout) | `sharedResizeObserver.test.ts` cases for `observeResizeAfterLayout`, and the Chromium trace test that opens a Lightbox gallery on a clamped caption and counts its layouts | A first read in the registration-time call, a first read before the browser's own first notification after layout, or a layout that the caption's first read forces |
| INV19 | A size check over Core component folders: each non-test behavior module over 300 lines or 3 KB gzip names its shared engine, or its record names why none fits | A private behavior module over the threshold with no shared engine and no recorded reason |
| INV20 | `useHotkeys.test.ts`, the 15 cases under "alt combos when Option rewrites the typed character": Option+A, the dead keys N, E, U, I and backtick with key code 229 and Option+E as Safari reports it (key code 69), Option+1, Option+Space and Option+Shift+/ on macOS; an AZERTY Mac's Option+A, a German Mac's Option+L registered as `alt+l` alone and as `alt+@`, a plain-ASCII Option character, an unmodified `é` on Digit2 with `2` registered alone, an input-method key, a text field, and a Polish AltGr letter on Windows. Real-device check: Safari 27 on macOS 27 with an OS-level Option+E fires `alt+e` on the page body and types é in a text field without firing it. Evidence gaps: Chrome on macOS, and an iPadOS hardware keyboard, have no real-device check | An Option combo that never fires on macOS, a match by key position for a plain-ASCII Option character or on Windows or Linux, an AltGr letter that fires a shortcut or is cancelled, or a shortcut that fires in a text field without `allowInInputs` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: the failure-signal cell still names only macOS ("never fires on macOS") and Windows or Linux ("or on Windows or Linux"), while INV20 now names iPadOS and iOS beside macOS, and ChromeOS and Android beside Windows and Linux. Suggested: "An Option combo that never fires on an Apple platform, a match by key position for a plain-ASCII Option character or on Windows, Linux, ChromeOS or Android, …".

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending CI: CI has not run on this head yet; it runs once the pull request is marked ready for review. The Apple-platform key-position matching, its guards and INV20 (approved at this head) hold up, the description states the Safari check on a real Mac at this head, and its platform claims match the tests.

The earlier comment-wording suggestions are still open and non-blocking.

Claims and files checked

Review mode: same-head; reason: none

  • changed rules (0): none

Claims:

  • Option shortcuts such as alt+a and alt+1 never fired on a Mac because the hook compared only the typed character, while Windows and Linux worked: verified (seven new cases fail with the base hook).
  • Apps had to write their own key-position matcher: context only; no caller in this repository registers an alt combo.
  • The documented combo now fires on macOS as on Windows and Linux, and iPadOS and iOS apply the same rule to a hardware keyboard: verified in code (useHotkeys.ts:182-188; the platform check matches iPad, iPhone and Mac values).
  • The key-position match applies only on Apple platforms, only to an alt combo, and only after the typed character missed: verified (useHotkeys.ts:170-188).
  • It applies only when Option typed a dead key or a single non-ASCII character: verified (useHotkeys.ts:179-181, useHotkeys.test.ts:385).
  • On every layout the US position wins, so AZERTY Option plus the key labeled A fires alt+q: verified (useHotkeys.test.ts:349).
  • A plain-ASCII Option character matches only as typed, so German Option+L fires alt+@, not alt+l: verified (useHotkeys.test.ts:332, :385, :394).
  • alt+shift+/ fires on Option+Shift+/ and alt+? does not: verified (useHotkeys.test.ts:367; ? has no position code at useHotkeys.ts:102).
  • Windows, Linux, ChromeOS and Android are unchanged, and an AltGr letter neither fires a ctrl+alt shortcut nor is cancelled: verified (useHotkeys.test.ts:412).
  • A combo without alt never matches by position, and text fields stay silent without allowInInputs: verified (useHotkeys.test.ts:403, :425).
  • The Hotkey.keys comment, the hook docs and the release note state the rule: verified.
  • INV20 states the rule, its verification row names the 15 cases, the Safari check and the open gaps, and the scope sentence names INV20: verified (react-component-runtime.md:107-111, :464-477, :706); the description's summary of INV20 names fewer platforms than the clause, which is narrower, not false.
  • Only the key position is available synchronously at keydown: consistent with the code's rationale.
  • Shift handling for combos that do not name shift is unchanged: verified (useHotkeys.ts:165-168).
  • The writing rubric results match the record: verified.
  • Red first, the Option+A, dead-key and Option+1 cases fail before the fix: verified (seven cases fail).
  • The AltGr case fails on the first commit and passes here: verified.
  • All 28 cases pass, 15 of them new: verified.
  • Each guard has a case that fails without it: verified (five guard mutations, each failing one case).
  • Safari on a real Mac fires alt+e on the page and types é in a field without firing it, checked at this head: accepted as the device statement (Safari 27.0, macOS 27.0, U.S. layout); the unit case at useHotkeys.test.ts:293 pins the page event.
  • A non-composing Option dead key reported with key code 229 now passes the input-method guard, and a key an input method composes is still ignored: verified (useHotkeys.ts:110-112, :232-237; useHotkeys.test.ts:277, :302).
  • Chrome on macOS and an iPadOS hardware keyboard have no device check: verified as stated in the record row.
  • The overlapping pull request does not touch the hook's key matching: verified (it changes only two records).
  • Public text has no internal context: verified.
  • Release note: alt+a, alt+1 and alt+space now fire on macOS, and iPadOS and iOS apply the same rule: verified in code and tests.
  • Release note: the AZERTY, German, shifted-punctuation, unchanged-platform and text-field statements: verified as above.
  • Release note: a patch bump for a fix: verified.

Files:

  • .changeset/hotkeys-alt-macos.md: clear.
  • docs/architecture/react-component-runtime.md: INV20 matches the code and its verification row's evidence is stated at this head; its failure-signal cell names fewer platforms than the clause (non-blocking).
  • packages/core/src/hooks/useHotkeys.doc.mjs: consistent with INV20; the reflow is formatting only.
  • packages/core/src/hooks/useHotkeys.test.ts: clear.
  • packages/core/src/hooks/useHotkeys.ts: matcher and guard clear; comment-wording suggestions (non-blocking).

Automated review (maintainer link)

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 19, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec cfc4d54

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 19, 2026

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. INV20 is approved by an engineering owner at this head, CI has passed here, the Safari check on a real Mac still applies across the merge of main, and every release-note and description claim matches the code and tests.

The earlier wording suggestions on three code comments in useHotkeys.ts and on INV20's failure-signal cell are still open and non-blocking.

Claims and files checked

Review mode: same-head; reason: none

  • changed rules (0): none

Claims:

  • Option shortcuts such as alt+a and alt+1 never fired on a Mac because the hook compared only the typed character, while Windows and Linux worked: verified (seven new cases fail with the base hook).
  • Apps had to write their own key-position matcher: context only; no caller in this repository registers an alt combo.
  • The documented combo now fires on macOS, and iPadOS and iOS apply the same rule to a hardware keyboard: verified in code (useHotkeys.ts:182-188; the platform check matches Mac, iPad and iPhone values).
  • The key-position match applies only on Apple platforms, only to an alt combo, and only after the typed character missed: verified (useHotkeys.ts:170-188).
  • It applies only when Option typed a dead key or a single non-ASCII character: verified (useHotkeys.ts:179-181, useHotkeys.test.ts:385).
  • On every layout the US position wins, so AZERTY Option plus the key labeled A fires alt+q: verified (useHotkeys.test.ts:349).
  • A plain-ASCII Option character matches only as typed, so German Option+L fires alt+@, not alt+l: verified (useHotkeys.test.ts:385, :394).
  • alt+shift+/ fires on Option+Shift+/ and alt+? does not: verified (useHotkeys.test.ts:367; ? has no position code at useHotkeys.ts:74-86).
  • Windows, Linux, ChromeOS and Android are unchanged, and an AltGr letter neither fires a ctrl+alt shortcut nor is cancelled: verified (useHotkeys.test.ts:412).
  • A combo without alt never matches by position, and text fields stay silent without allowInInputs: verified (useHotkeys.test.ts:321, :403, :425).
  • The Hotkey.keys comment, the hook docs and the release note state the rule: verified.
  • INV20 states the rule, its verification row names the 15 cases, the Safari check and the open gaps, and the scope sentence names INV20: verified (react-component-runtime.md:109-111, :472-485, :714).
  • Only the key position is available synchronously at keydown: consistent with the code's approach.
  • Shift handling for combos that do not name shift is unchanged: verified (useHotkeys.ts:165-168).
  • The writing rubric results match the record: verified.
  • Red first, the Option+A, dead-key and Option+1 cases fail before the fix: verified (seven new cases fail with the base hook).
  • The AltGr case fails on the first commit and passes here: verified (the first commit had no platform gate; the case passes at this head).
  • All 28 cases pass, 15 of them new: verified (13 cases on the base, 28 at this head, all passing in CI).
  • Each guard has a case that fails without it: verified (six guard mutations, each failing one case).
  • Safari on a real Mac fires alt+e on the page and types é in a field without firing it, checked at the last authored head: accepted as the device statement; it still applies because the merge of main changes neither the hook nor its imports (useHotkeys.test.ts:293 pins the page event).
  • A non-composing Option dead key reported with key code 229 now passes the input-method guard, and a key an input method composes is still ignored: verified (useHotkeys.ts:110-112, :232-237; useHotkeys.test.ts:277, :302).
  • Chrome on macOS and an iPadOS hardware keyboard have no device check: verified as stated in the record row.
  • The overlapping pull request does not touch the hook's key matching: verified (it changes only two records).
  • Public text has no internal context: verified.
  • Release note: alt+a, alt+1 and alt+space now fire on macOS, and iPadOS and iOS apply the same rule: verified (useHotkeys.test.ts:267, :312, :376).
  • Release note: the AZERTY, German, shifted-punctuation, unchanged-platform and text-field statements: verified as above.
  • Release note: a patch bump for a fix: verified.

Files:

  • .changeset/hotkeys-alt-macos.md: clear.
  • docs/architecture/react-component-runtime.md: INV20 matches the code; its failure-signal cell names fewer platforms than the clause (non-blocking).
  • packages/core/src/hooks/useHotkeys.doc.mjs: consistent with INV20; the reflow is formatting only.
  • packages/core/src/hooks/useHotkeys.test.ts: clear.
  • packages/core/src/hooks/useHotkeys.ts: matcher and guard clear; comment-wording suggestions (non-blocking).

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 20, 2026 01:25
# Conflicts:
#	docs/architecture/react-component-runtime.md
@cixzhang
cixzhang marked this pull request as draft November 20, 2026 03:39
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec c229a9d

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved: CI has passed on this head.

INV20 is approved by an engineering owner at this head, every release-note and description claim matches the code and tests, and the Safari check on a real Mac still applies across the merges of main, which change only the record among this pull request's files.

The earlier wording suggestions on three code comments in useHotkeys.ts and on INV20's failure-signal cell are still open and non-blocking.

Claims and files checked

Review mode: same-head; reason: none

  • changed rules (0): none

Claims:

  • Option shortcuts such as alt+a and alt+1 never fired on a Mac because the hook compared only the typed character, while Windows and Linux worked: verified (seven new cases fail with the base hook).
  • Apps had to write their own key-position matcher: context only; no caller in this repository registers an alt combo.
  • The documented combo now fires on macOS, and iPadOS and iOS apply the same rule to a hardware keyboard: verified in code (useHotkeys.ts:182-188; the platform check matches Mac, iPad and iPhone values).
  • The key-position match applies only on Apple platforms, only to an alt combo, and only after the typed character missed: verified (useHotkeys.ts:170-188).
  • It applies only when Option typed a dead key or a single non-ASCII character: verified (useHotkeys.ts:179-181, useHotkeys.test.ts:385).
  • On every layout the US position wins, so AZERTY Option plus the key labeled A fires alt+q: verified (useHotkeys.test.ts:349).
  • A plain-ASCII Option character matches only as typed, so German Option+L fires alt+@, not alt+l: verified (useHotkeys.test.ts:385, :394).
  • alt+shift+/ fires on Option+Shift+/ and alt+? does not: verified (useHotkeys.test.ts:367; ? has no position code at useHotkeys.ts:74-86).
  • Windows, Linux, ChromeOS and Android are unchanged, and an AltGr letter neither fires a ctrl+alt shortcut nor is cancelled: verified (useHotkeys.test.ts:412).
  • A combo without alt never matches by position, and text fields stay silent without allowInInputs: verified (useHotkeys.test.ts:321, :403, :425).
  • The Hotkey.keys comment, the hook docs and the release note state the rule: verified.
  • INV20 states the rule, its verification row names the 15 cases, the Safari check and the open gaps, and the scope sentence names INV20: verified (react-component-runtime.md:107-111, :472-485, :714).
  • Only the key position is available synchronously at keydown: consistent with the code's approach.
  • Shift handling for combos that do not name shift is unchanged: verified (useHotkeys.ts:165-168).
  • The writing rubric results match the record: verified.
  • Red first, the Option+A, dead-key and Option+1 cases fail before the fix: verified (seven new cases fail with the base hook).
  • The AltGr case fails on the first commit and passes here: verified (the first commit's hook fails it; it passes at this head).
  • All 28 cases pass, 15 of them new: verified (13 cases on the base, 28 at this head, all passing).
  • Each guard has a case that fails without it: verified (removing the plain-ASCII, alt or dead-key guard each fails one case).
  • Safari on a real Mac fires alt+e on the page and types é in a field without firing it, checked at the last authored head: accepted as the device statement; it still applies because the merges of main change neither the hook nor its imports (useHotkeys.test.ts:293 pins the page event).
  • A non-composing Option dead key reported with key code 229 now passes the input-method guard, and a key an input method composes is still ignored: verified (useHotkeys.ts:105-112, :232-237; useHotkeys.test.ts:277, :302).
  • Chrome on macOS and an iPadOS hardware keyboard have no device check: verified as stated in the record row.
  • The overlapping pull request does not touch the hook's key matching: verified (it changes only two records).
  • Public text has no internal context: verified.
  • Release note: alt+a, alt+1 and alt+space now fire on macOS, and iPadOS and iOS apply the same rule: verified (useHotkeys.test.ts:267, :312, :376).
  • Release note: the AZERTY, German, shifted-punctuation, unchanged-platform and text-field statements: verified as above.
  • Release note: a patch bump for a fix: verified.

Files:

  • .changeset/hotkeys-alt-macos.md: clear.
  • docs/architecture/react-component-runtime.md: INV20 matches the code, and the re-padded table keeps main's wording; its failure-signal cell names fewer platforms than the clause (non-blocking).
  • packages/core/src/hooks/useHotkeys.doc.mjs: consistent with INV20; the reflow is formatting only.
  • packages/core/src/hooks/useHotkeys.test.ts: clear.
  • packages/core/src/hooks/useHotkeys.ts: matcher and guard clear; comment-wording suggestions (non-blocking).

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 20, 2026 15:52
@cixzhang
cixzhang merged commit 1ad6b68 into main Nov 20, 2026
157 checks passed
@github-actions
github-actions Bot deleted the lane2/hotkeys-alt-macos branch November 21, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — c229a9d3 Deployed Nov 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. lane:2 Astryx fix-loop lane 2 owns this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant