Skip to content

fix(Kbd): platform-aware mod key display - #722

Merged
cixzhang merged 1 commit into
mainfrom
navi/fix/kbd-platform-detection
Mar 19, 2026
Merged

cixzhang merged 1 commit into
mainfrom
navi/fix/kbd-platform-detection

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Addresses P1 finding from hardening sprint #719:

  • P1: Always shows macOS ⌘, no platform detection — The mod key now resolves to ⌘ on macOS and Ctrl on Windows/Linux. Detection is SSR-safe (guards typeof navigator) and cached after first call.

Implementation

  • Added isMac() helper with lazy evaluation: checks navigator.platform against /Mac|iPhone|iPad|iPod/, caches the result, and returns false during SSR (typeof navigator === 'undefined')
  • Added getKeyDisplay() function that handles the dynamic mod key resolution and falls back to the static KEY_DISPLAY map
  • Removed mod from the static KEY_DISPLAY map — it's now resolved dynamically

Test plan

  • Updated existing tests for jsdom environment (non-Mac → expects Ctrl)
  • Added new test for mod key rendering on non-Mac platforms
  • All 10 tests pass

- mod key now shows ⌘ on macOS and Ctrl on other platforms
- SSR-safe with lazy detection (cached after first call)
- Resolves P1 finding from hardening issue #719

Co-authored-by: Navi <[email protected]>
@cixzhang cixzhang added the hardening Component hardening and quality sweep label Mar 19, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 19, 2026
@github-actions

github-actions Bot commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

Kbd · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 199B N/A
Lines of Code N/A 97 -
Complexity N/A Medium (10) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 10.7KB 17.0KB 2.6KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang
cixzhang merged commit 4fd8084 into main Mar 19, 2026
11 checks passed
@cixzhang
cixzhang deleted the navi/fix/kbd-platform-detection branch March 20, 2026 16:59
cixzhang added a commit that referenced this pull request Apr 26, 2026
- mod key now shows ⌘ on macOS and Ctrl on other platforms
- SSR-safe with lazy detection (cached after first call)
- Resolves P1 finding from hardening issue #719

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
- mod key now shows ⌘ on macOS and Ctrl on other platforms
- SSR-safe with lazy detection (cached after first call)
- Resolves P1 finding from hardening issue #719

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
- mod key now shows ⌘ on macOS and Ctrl on other platforms
- SSR-safe with lazy detection (cached after first call)
- Resolves P1 finding from hardening issue #719
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. hardening Component hardening and quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant