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
Accessibility Fix: Add tooltips to import, export, and modal close buttons #667
Accessibility Fix: Add tooltips to import, export, and modal close buttons #667
Conversation
Note: these should really be translation ready. Is there something already included within Playground that we can wrap this in, some kind of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the insight, @aurooba
I've got a question about duplicating the aria-label
value when the title
exists, but otherwise this seems like a good change we can merge quickly.
unfortunately there's no system in place yet here for translation strings, unless I'm mistaken.
return ( | ||
<button | ||
id="export-playground--btn" | ||
className={css.btn} | ||
aria-label="Download Playground export as ZIP file" | ||
aria-label={exportButtonAriaLabel} | ||
title={exportButtonAriaLabel} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the title set is the aria-label
necessary? I was led to believe that it becomes redundant at that point, and only matters if the aria-label
value is different than the title
, in which case its value is preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Although screen-readers will read the title
if it's there (in some cases only), they prefer aria-label
and users can set preferences where only aria-label
is read. So it's considered a better practice to include both. Here's some more information: https://www.a11yproject.com/posts/title-attributes/
Actually, the Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're here, some labeling notes.
@@ -9,11 +9,15 @@ export default function ExportButton() { | |||
if (!playground) { | |||
return null; | |||
} | |||
|
|||
const exportButtonAriaLabel = 'Download Playground export as ZIP file'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Save verbosity?
const exportButtonAriaLabel = 'Download Playground export as ZIP file'; | |
const exportButtonAriaLabel = 'Download configuration .zip file'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest a further change, Export configuration .zip file
@@ -8,6 +8,7 @@ export default function ImportButton() { | |||
const [isOpen, setOpen] = useState(false); | |||
const openModal = () => setOpen(true); | |||
const closeModal = () => setOpen(false); | |||
const importButtonAriaLabel = 'Open Playground import window'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text is redundant.
const importButtonAriaLabel = 'Open Playground import window'; | |
const importButtonAriaLabel = 'Import configuration'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
export default function Modal(props: ModalProps) { | ||
const closeBtnAriaLabel = 'Close import window'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the modal provides current context, can shorten to just Close.
const closeBtnAriaLabel = 'Close import window'; | |
const closeBtnAriaLabel = 'Close'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@alexstine Good call on changing the labels, I didn't want to express any opinions there but I agree that the actual language could be updated, and I agree with your suggestions. Regarding the Should we skip using For reference, in the Block Editor, the tooltip component uses the @ariakit/react Tooltip component |
Co-authored-by: aurooba <aurooba@auroobamakes.com Co-authored-by: alexstine <alex.stine@yourtechadvisors.com>
This reverts commit 35e98e0.
@aurooba Why not use the one from Gutenberg WordPress components? https://github.com/WordPress/gutenberg/tree/trunk/packages/components/src/tooltip |
This is lovely @aurooba, thank you so much!
Yeah, the button could be much clearer about its purpose. Let's take a step back and think of what a clearer button would look like. Maybe let's replacing these icons with textual buttons like |
## What is this PR doing? Puts additional actions in a single, accessible dropdown menu instead of jamming more ambiguous icons in the "toolbar". Closes #667
What is this PR doing?
This PR adds tooltips to the import, export, and modal close buttons.
What problem is it solving?
While they already have
aria-label
visually users still need the tooltips so they can understand what these icon buttons do without interacting with them first.How is the problem addressed?
A
title
attribute has been added to eachbutton
element that has the same text as thearia-label
helper text.Testing Instructions
Screenshot