Skip to content

KeybindingHint: Fix platform-aware Mod ordering - #8762

Open
siddharthkp wants to merge 7 commits into
mainfrom
fix/keybinding-hint-mod-order
Open

siddharthkp wants to merge 7 commits into
mainfrom
fix/keybinding-hint-mod-order

Conversation

@siddharthkp

@siddharthkp siddharthkp commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Bug

Mod means Command on Apple devices and Control on other devices. KeybindingHint displayed the correct key name, but sorted Mod as an ordinary key. Shortcut hints put this key after Shift instead of before it. Screen reader descriptions had the same error.

Fix

Give Mod the same sorting priority as Meta on Apple devices and Control on other devices. Use this order in displayed shortcuts and screen reader descriptions. The displayed key names do not change.

Before and After

image

Rollout strategy

  • No changes needed in github/github-ui
  • Needs changes in github/github-ui
  • Ships with feature flag(s)
  • Not sure
  • None

Testing & Reviewing

  • All 33 KeybindingHint unit tests pass locally. Regression tests cover mixed-case Mod, all three platform groups, and accessible shortcut sequences.
  • Verified live before/after examples for full, condensed, mixed-modifier, and sequence shortcuts on Apple, Windows, and Linux / Android.
  • Verified that Shift+Meta+K has the same order before and after the fix on all three platform groups.
  • Updated visual regression snapshots for the changed order.

@changeset-bot

changeset-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2f6a38b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@siddharthkp siddharthkp added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Nov 16, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8762 November 16, 2026 12:14 Inactive
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Nov 16, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8762 November 16, 2026 12:26 Inactive
@github-actions

Copy link
Copy Markdown
Contributor

Uh oh! @siddharthkp, at least one image you shared is missing helpful alt text. Check your pull request body to fix the following violations:

  • Images should have meaningful alternative text (alt text) at line 15

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

🤖 Beep boop! This comment was added automatically by github/accessibility-alt-text-bot.

@siddharthkp
siddharthkp marked this pull request as ready for review November 23, 2026 22:28
@siddharthkp
siddharthkp requested a review from a team as a code owner November 23, 2026 22:28
@siddharthkp
siddharthkp requested review from tay1orjones and a balanced review from Copilot November 23, 2026 22:28

Copilot AI 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.

🟢 Approval recommended

No active review issues are recorded for the platform-aware modifier-ordering change.

No open issues 🎉

What changed in this PR

Fixes platform-aware Mod ordering in Primer React’s KeybindingHint, keeping displayed shortcuts and screen reader descriptions consistent without changing key names.

Changes:

  • Sorts Mod alongside Meta on Apple platforms and Control elsewhere.
  • Adds regression coverage for mixed-case modifiers and accessible sequences across three platform groups.
  • Documents the behavior, adds a patch changeset, and adjusts timing in a TreeView test.
File Description
packages/​react/​src/​TreeView/​TreeView.test.tsx Uses fake timers and a synchronous focus assertion in a typeahead test.
packages/​react/​src/​KeybindingHint/​props.ts Documents platform-aware Mod sorting.
packages/​react/​src/​KeybindingHint/​KeybindingHint.test.tsx Tests visual and accessible modifier ordering across platforms.
packages/​react/​src/​KeybindingHint/​components/​utils.ts Resolves Mod sorting priority by platform.
packages/​react/​src/​KeybindingHint/​components/​Chord.tsx Passes the current platform into chord sorting.
.changeset/​fix-keybinding-hint-mod-order.md Records the fix for a patch release.

Review effort: Balanced

@siddharthkp

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

…od-order

# Conflicts:
#	packages/react/src/TreeView/TreeView.test.tsx

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

:copilot:: Resolved in d024005. Build, tests, type checking, lint, and formatting checks passed.

@github-actions
github-actions Bot temporarily deployed to storybook-preview-8762 November 24, 2026 12:35 Inactive

it('supports multiple typed characters', async () => {
vi.useFakeTimers()
vi.useFakeTimers({toFake: ['setTimeout', 'clearTimeout']})

@siddharthkp siddharthkp Nov 24, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Had to add this to pass CI because without this setup, Vitest throws "the timers APIs are not mocked."

@siddharthkp

siddharthkp commented Nov 24, 2026 •

Copy link
Copy Markdown
Member Author

Ack for failing CI in github-ui, there are tests that expect a specific order. I'll fix those tests before merging this PR (https://github.com/github/github-ui/pull/46458)

@primer-integration

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Failed  Changes   Failed
Failed  CI   Failed
Failed  VRT   Failed
Passed  Projects   Passed

Changes check could not confirm that this PR only changes the expected integration paths. Open the Changes run for the unexpected files or error details.

This check is not required for merging.

Integration PRs should only change:

  • node_modules/**
  • packages/primer/package.json
  • package-lock.json
  • Top-level npm-pack tarballs in packages/primer/.prc-integration-tarballs/, named for dependencies or devDependencies in the PR base's Primer workspace manifest.
  • Removal only (not additions, edits, or renames) of top-level patches in packages/patch-packages/patches/ for packages whose tarballs are added, modified, or renamed in this PR. Existing workflows also support removing @primer/react patches without tarballs.

Fixes made only in an integration PR do not reach github-ui's main branch. After the upstream Primer PR merges, other integration PRs and release PRs can fail because they do not include those fixes.

Before merging your Primer PR:

  1. Keep changes backward compatible. If that is not possible, discuss the breaking change before merging.
  2. If tests are over-reaching and testing implementation details, fix and merge those tests in github-ui first, then merge the Primer change.
  3. If the change and tests are both valid but tests need updating, first make and merge tests that pass with both the old and new Primer versions, as you would for a feature flag. Then merge the Primer change.

Please talk to the release conductor or ask in #primer before merging your Primer PR.

CI check runs linting, type checking, and unit tests. Check the workflow logs for specific failures.

VRT check ensures that when visual differences are detected, the PR cannot proceed until someone acknowledges the changes by adding the "visual difference acknowledged" label.

Need help? If you believe this failure is unrelated to your changes, please reach out to the Primer team for assistance.

This branch was successfully deployed

2 active deployments
storybook-preview-8762 — 2f6a38bc Deployed Nov 24, 2026 by github-actions[bot]
github-pages — 2f6a38bc Deployed Nov 24, 2026 by siddharthkp via deploy-preview #34515
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: failing Changes in this PR cause breaking changes in gh/gh integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants