fix(core): normalize Kbd esc and return aliases - #5657
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsKbd (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression110 added · 0 removed. View the report To accept these exact frames: Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
rubyycheung
left a comment
There was a problem hiding this comment.
Looks good from design. Normalizing and makes their visual output and accessible names consistent with the canonical and keys, without changing the established Kbd presentation.
|
Clarification: normalizing |



Summary
Kbd now normalizes the unambiguous
escandreturnaliases already accepted byuseHotkeys, so their visual glyphs and accessible names matchescapeandenter. This is a partial fix for #5403;metaandspaceremain open design/API decisions.Case
useHotkeysalready mapsescandreturnto the correspondingKeyboardEvent.keyvalues (useHotkeys.ts:64-74,132-133), but Kbd previously sent every token directly through its display and label fallbacks (Kbd.tsx:89-120). As a result,escrendered and announced asESC, whilereturnrendered and announced asRETURN.Fix
Kbd now normalizes the two aliases before display and accessible-label resolution (
Kbd.tsx:79-82,173-190). The touched lookup tables useMap, keeping arbitrary key names on the uppercase fallback instead of accidentally resolving inherited object properties (Kbd.tsx:64-120), and occurrence-qualified React keys preserve every badge when canonical and alias spellings repeat (Kbd.tsx:173-205). Component docs and the CLI/Storybook showcases now demonstrate the aliases (Kbd.doc.mjs:12-16,KbdModifierCombos.tsx:23-31,Kbd.stories.tsx:74-87).Scope
This intentionally handles only
escandreturn. It does not choose platform behavior formetaor a glyph forspace; those remain tracked in #5403. Existing empty-combo-segment behavior and the separateuseHotkeyslookup implementation are parser-hardening follow-ups, not part of this rendering fix.Testing
pnpm exec vitest run packages/core/src/Kbd/Kbd.test.tsx packages/core/src/hooks/useHotkeys.test.ts— 2 files, 36 tests passed.pnpm -F @astryxdesign/core typecheck— passed.pnpm -F @astryxdesign/core typecheck:docs— passed.pnpm -F @astryxdesign/core build— 581 files compiled and verified.pnpm check:repo— all repository integrity checks passed.origin/main: the alias regression cases failed becauseescrendered/announced asESCandreturnasRETURN. With the fix, standalone, uppercase, combo, semantic-equivalence, repeated-key, and accessible-name cases pass.constructor/__proto__failed through prototype-backed lookup; the committed regression tests now pass.Refs #5403