Uh oh!
There was an error while loading. Please reload this page.
Add workaround for Chrome bug where KeybindingHint in combination with aria-labelledby results in incorrect label - #5818
Conversation
🦋 Changeset detectedLatest commit: 6b96334 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks! |
size-limit report 📦
|
| ) | ||
| const triggerEl = getByRole('button', {name: 'Heart'}) | ||
| expect(triggerEl).toHaveAccessibleDescription('Love is all around (command h)') | ||
| expect(triggerEl).toHaveAccessibleDescription('Love is all around (command h)') |
There was a problem hiding this comment.
Note: This is indicative of the one potential breaking change I see for dotcom - we may need to update some test selectors to remove spaces around the keybinding hint in the labels. This is an intentional change.
KeybindingHintrenders the key symbols asaria-hiddenspans and the key names asVisuallyHiddenspans to provide a good experience for both sighted and screen reader users.However, there is a bug in Chrome where
aria-hiddentext is included in a label generated usingaria-labelledby. More context from https://github.com/github/accessibility/issues/8018#issuecomment-2751656621:To work around this bug, I've taken the approach proposed in the quote to update
TooltipV2to exclude the keybinding hint from the id-tagged container. Then I added the keybinding hint text as a plain hidden string inside that container.Before in VoiceOver/Chrome:
After:
Note this isn't a perfect example because obviously "question mark" is combined with "shift", but it's pulled from storybook so I just kept it. Intuitively you might think the label should be "shift + question mark", but when read by a screen reader this can result in the awkward label "shift plus question mark" - it's better to just exclude the punctuation here.
Changelog
New
Changed
Fixed a Chrome bug impacting accessible labels rendered by
TooltipV2with thekeybindingHintprop.Removed
Rollout strategy
Testing & Reviewing
Merge checklist