-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Improve the image block lightbox translations, labelling, and escaping #50962
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
Improve the image block lightbox translations, labelling, and escaping #50962
Conversation
|
Size Change: 0 B Total Size: 1.41 MB ℹ️ View Unchanged
|
|
Flaky tests detected in 5c3ca57. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5080636880
|
alexstine
left a comment
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.
Changes make sense to me.
artemiomorales
left a comment
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 looking at this! These changes look good to me 👍
|
Cherry picked for Gutenberg 15.9 RC2 |
#50962) * Fix translatable labels and escaping. * Improve labels. * Adjust test. * Simplify labels and use aria-label for the dialog. * Add missing button type attribute. * Fix typo.
| data-wp-on.click="actions.core.image.hideLightbox" | ||
| > | ||
| <button aria-label="Close lightbox" class="close-button" data-wp-on.click="actions.core.image.hideLightbox"> | ||
| <button type="button" aria-label="$close_button_label" class="close-button" data-wp-on.click="actions.core.image.hideLightbox"> |
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.
We should probably also escape the close button label here.
| <div data-wp-body="" class="wp-lightbox-overlay" | ||
| data-wp-bind.role="selectors.core.image.roleAttribute" | ||
| aria-labelledby="$image_lightbox_id" | ||
| aria-label="$dialog_label" |
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.
We should probably also escape the dialog label here.
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.
Only user provided texts are escaped in WordPress core.
WordPress#50962) * Fix translatable labels and escaping. * Improve labels. * Adjust test. * Simplify labels and use aria-label for the dialog. * Add missing button type attribute. * Fix typo.
Fixes #50959
Note: this PR is a the result of a team coding session with @aristath, @carolinan, @SergeyBiryukov, and @afercia.
What?
lightboxis. That term is way too technical. As a user, I'm only interested in understanding what an UI control does.type="button"attribute: potentially, the may submit a form when the block is rendered within a form.Why?
How?
lightboxand simplifies the labels. New labels:aria-labellednbytoaria-label: this allows to provide a default label. Also, prevents potentially duplicated IDs and allows to simplify the code.type="button"attributes.Nnte:
The Close button misses a tooltip. Icon-buttons should always visually expose their accessible name. In the admin, we're using the Tooltip component for this. Not sure how to solve this for the front end so I'm keeping this point out of this PR for now.
Testing Instructions
Core blocksin the Gutenberg Experiments settings page.Enlarge image: {alt text here}.Enlarge image.Image.aria-haspopup="dialog"attribute makes screen reader announce something along the lines ofdialog pop-up.dialogorweb dialog.Testing Instructions for Keyboard
Screenshots or screencast
Screenshots with Safari + VoiceOver announcing the Lightbox button and dialog:
Button:
Dialog: