Skip to content
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

Add aria-describedby in the featured image preview #14593

Closed
wants to merge 4 commits into from

Conversation

Jackie6
Copy link
Contributor

@Jackie6 Jackie6 commented Mar 23, 2019

Description

Fix #14416

How has this been tested?

  • Local
  • unit tests
  • Local e2e tests
  • Browser testing

Types of changes

Add aria-describedby in the image button of the feature image preview.

  • when the image has an alt text, the aria-describedby should be Current image: altText
  • when the image doesn't have an alt text, the aria-describedby should be The current image has no alternative text. The file name is: fileName

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@gziolo gziolo added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended labels Apr 2, 2019
@gziolo gziolo requested a review from afercia April 2, 2019 22:06
@gziolo gziolo dismissed their stale review April 2, 2019 22:06

Feedback was addressed

@gziolo gziolo added the Needs Accessibility Feedback Need input from accessibility label Apr 10, 2019
jorgefilipecosta added a commit that referenced this pull request Apr 11, 2019
## Description
Related in #14416 we have a similar issue but for the featured image that issue is being addressed on #14593.

Here the solution is not as perfect, as we don't have the alt text of the poster image only the URL was saved in the attributes.

## How has this been tested?
I used the voice over utility and I checked that a descriptive message is announced after the select/replace poster image button gains focus.
mchowning pushed a commit to mchowning/gutenberg that referenced this pull request Apr 15, 2019
…14752)

## Description
Related in WordPress#14416 we have a similar issue but for the featured image that issue is being addressed on WordPress#14593.

Here the solution is not as perfect, as we don't have the alt text of the poster image only the URL was saved in the attributes.

## How has this been tested?
I used the voice over utility and I checked that a descriptive message is announced after the select/replace poster image button gains focus.
if ( media ) {
const mediaSize = applyFilters( 'editor.PostFeaturedImage.imageSize', 'post-thumbnail', media.id, currentPostId );
if ( has( media, [ 'media_details', 'sizes', mediaSize ] ) ) {
mediaWidth = media.media_details.sizes[ mediaSize ].width;
mediaHeight = media.media_details.sizes[ mediaSize ].height;
mediaSourceUrl = media.media_details.sizes[ mediaSize ].source_url;
mediaAltText = media.media_details.sizes[ mediaSize ].alt_text;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand how the PostFeaturedImage works (@gziolo is this still working?), however seems to me alt_text is never a property of media.media_details.sizes[ mediaSize ] and instead it's always media.alt_text. If I'm correct, this will fail and will use the wrong description for images that actually do have an alt text.

hidden
>
{ mediaAltText ?
sprintf( __( 'Current image: %s' ), mediaAltText ) :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use a translators comment /* translators: %s: image alt text */

>
{ mediaAltText ?
sprintf( __( 'Current image: %s' ), mediaAltText ) :
__( 'The current image has no alternative text. The file name is: ' + imageFilename )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of concatenation, should use sprintf() and a translator comment /* translators: %s: image file name */

Copy link
Contributor

@afercia afercia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Jackie6 and sorry for the late review.

I left some comments regarding a few points that seems to me should be addressed.

Also, a couple more issues:

1
When setting an image and the media modal closes, focus should be moved back to the button that was previously focused. This can be either the Set featured image button (which turns in the preview button) or the Replace Image one, depending on the workflow. On master, this seems to work correctly. On this branch seems it isn't.

I guess that instead of adding one more MediaUploadCheck, we should try to reduce their number to avoid the component is unmounted and remounted. See for example a similar issue in #14415

2
On master, there's some margin between the image and the Replace button (see also the focus indication around the image when the modal closes):

Screenshot 2019-05-09 at 14 29 54

On this branch, there's no margin (and focus is not moved back):

Screenshot 2019-05-09 at 14 36 22

@afercia afercia removed the Needs Accessibility Feedback Need input from accessibility label May 9, 2019
@Jackie6
Copy link
Contributor Author

Jackie6 commented May 11, 2019

@afercia Thanks for the comments. Will do it next week!

@afercia
Copy link
Contributor

afercia commented Sep 21, 2020

Closing as superseded by #24888.

@afercia afercia closed this Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Media Anything that impacts the experience of managing media [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Describe the image in the featured image preview
4 participants