-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tooltip keybinding hints #5252
base: main
Are you sure you want to change the base?
Tooltip keybinding hints #5252
Conversation
🦋 Changeset detectedLatest commit: b30905d 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 |
Uh oh! @iansan5653, the image you shared is missing helpful alt text. Check your pull request body. 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.
|
👋 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! |
Uh oh! @iansan5653, the image you shared is missing helpful alt text. Check your pull request body. 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.
|
The bot is totally wrong, my images do have alt text. Strange 😕 Also wow that's a lot of Actions comments 😄 |
size-limit report 📦
|
@iansan5653 So excited to see this added. 🎉 Could we add a few tweaks in?
|
I'm happy to make those changes (I think that design looks much better!) however as I mentioned on the call that does increase the 'blast radius' of this PR by impacting existing uses of There are very few places where this component is currently used in dotcom, since it's still relatively new. I actually think the bigger risk than breaking existing usages may just be introducing yet another design for keyboard shortcut hints. We already have so much disparity because there's no 'official' Primer component for this. Currently there are two distinct designs:
Take the PR homepage for example - on the same screen you have two different designs used for the same thing 🙃: Given that very few places are using the React component now, introducing yet another design might just make the problem worse by eventually having three different designs on the same view. I think we need a broader initiative here to standardize this design and make it work both in tooltips and in menus/text/etc. And use it everywhere except maybe in user-generated Markdown content. Also worth noting it looks like you have a different font size for tooltips in your designs than what is currently implemented in the |
Update: Per our discussion in Slack, I've made two changes:
You can see the changes in Storybook:
NOTE: I don't think the updated primary button design looks great 😕 . The problem is the background color token (from counter) looks great against tooltip backgrounds but not against button backgrounds. We could just ignore this, since it's very uncommon in reality. Or we could introduce a third variant for the new design ( |
Closes #4759
Currently we have minimal support for keybinding hints on
IconButton
andTooltipV2
by simply rendering the shortcuts as a string separated by a comma. But now that we have aKeybindingHint
component that renders visually nice keybinding hints, there's no reason we can't migrate to the new component and get a much nicer visual presentation.This PR does that, updating
TooltipV2
to add akeybindingHint
prop that renders the hint usingKeybindingHint
at the end of the tooltip:In addition, this also requires updating
IconButton
to take advantage of the new functionality.IconButton
does already havekeyshortcuts
, which assigns thearia-keyshortcuts
attribute and also adds the shortcut to the label. For consistency, and considering that this prop is entirely unused in github/github, I decided to rename this tokeybindingHint
. I think this more explicitly implies that the prop is not binding a shortcut, it's just rendering a visual hint. It also better ties the prop to the underlying component, which does have some requirements about the format of the string.Accessibility concerns
aria-keyshortcuts
Currently we are still sending the keybinding hint string to the
aria-keyshortcuts
prop inIconButton
. I'm not sure that we actually should keep doing this, because this causes the hint to be presented in both the label and the ARIA attribute, which could be annoying / repetitive. We could alternatively remove the hint from the label, but support foraria-keyshortcuts
is not universal. In addition, the format of the string expected byKeybindingHint
does not necessarily match the format expected byaria-keyshortcuts
.aria-label
bugThere is one known bug with rendering
KeybindingHint
as part of the label. Normally, the plain-text representation ofKeybindingHint
is actually very good - it replaces the symbolic key icons with full plain-text key names to ensure that screen readers pronounce them accurately. However, there is a bug in Chrome that causesaria-hidden
regions inside popovers to become part of the generated accessible name, which means that the symbolic key icons are incorrectly becoming part of the name.So, for example, the accessible name for the bold button pictured above is
Bold (command ⌘ b B)
instead of the expectedBold (command b)
😞.We could work around this with some effort, but I'm not sure that it's worth it since this is a bug in Chrome (does not reproduce in Safari) and is not excessively disruptive. If we do feel that this is a blocker I can spend a bit more time trying to come up with a workaround. We'd probably have to exclude the
KeybindingHint
from the accessible name by moving thearia-labelledby
target to only wrap some of the tooltip contents, and then append a visually hidden, accessible plain-text version of the hint onto the name instead. Not terrible but not trivial either.Changelog
New
TooltipV2
through the newkeybindingHint
prop, which renders aKeybindingHint
component under the hoodChanged
keyshortcuts
prop onIconButton
tokeybindingHint
(deprecating the old prop name) and updates it to render aKeybindingHint
component instead of a plain stringRemoved
Rollout strategy
Testing & Reviewing
Merge checklist