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

Cover Block: fixed background image fails a11y test #49902

Closed
kstarcher opened this issue Apr 18, 2023 · 3 comments · Fixed by #50990
Closed

Cover Block: fixed background image fails a11y test #49902

kstarcher opened this issue Apr 18, 2023 · 3 comments · Fixed by #50990
Assignees
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@kstarcher
Copy link

Description

This is related to #30505 which was fixed and closed, but a slightly different issue.

When a regular background image is used in a cover block, the alt text is correctly added and displayed in an img tag. However, if the "Fixed background" or "Repeated background" options are checked, the img tag switches to a div with role="img". SiteImprove then flags it as not having alt text, because an element with role="img" is supposed to have alt text. This happens regardless of whether or not the image has alt text in the media library.

Step-by-step reproduction instructions

  1. Add a cover image block and give it an image background
  2. Under "Media Settings", give it alt text
  3. Flip the "Fixed Background" switch on
  4. Save and view, then run SiteImprove to test for accessibility

Screenshots, screen recording, code snippet

Screenshot 2023-04-18 at 10 37 15 AM

Screenshot 2023-04-18 at 10 38 25 AM

Environment info

WP 6.2 using a custom theme. Gutenberg not installed, just using block editor.
Mac Chrome with SiteImprove extension.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@cngodles
Copy link

True. If the <div> element has the attribute/value pair of role="img", it either needs an aria-label or a role to be set to presentation. This is a perfect example of automated testing catching this condition.

@bph bph added the [Block] Cover Affects the Cover Block - used to display content laid over a background image label Apr 18, 2023
@kathrynwp kathrynwp added [Type] Enhancement A suggestion for improvement. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). labels May 10, 2023
@joedolson
Copy link
Contributor

This should be able to cover both cases: an image that is presentational or an image that contains content. I don't think users should generally add content images into a fixed background image, but...they probably will, so we might as well support that accessibly.

This means that the fixed cover background should support an alt text field. If the alt text field has content, then the div should have a role of img and an aria-label containing the alt text.

If the alt text does not have content, then the role=imgshould be omitted. Role=presentation is not required, as that's the native role for a div element.

@carolinan
Copy link
Contributor

The block already has an alt text input field when an image is selected, so we should ensure it is not hidden when the fixed or repeated options are enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants