-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
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
|
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.
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.
@@ -92,10 +93,10 @@ function render_block_core_image( $attributes, $content ) { | |||
data-wp-on.mousewheel="actions.core.image.hideLightbox" | |||
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.
@@ -82,7 +83,7 @@ function render_block_core_image( $attributes, $content ) { | |||
$body_content | |||
<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?
lightbox
is. 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?
lightbox
and simplifies the labels. New labels:aria-labellednby
toaria-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 blocks
in 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
.dialog
orweb dialog
.Testing Instructions for Keyboard
Screenshots or screencast
Screenshots with Safari + VoiceOver announcing the Lightbox button and dialog:
Button:
Dialog: