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

Carousel: Improve keyboard and screen reader accessibility #42134

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from

Conversation

ryelle
Copy link
Member

@ryelle ryelle commented Feb 27, 2025

Fixes #39926, though it seemed to be opposite when I tested (clicking gave the carousel, while keyboard took me to the attachment page). Throughout the images and galleries, the behavior between mouse and keyboard are now the same. This also improves the carousel keyboard behavior by creating a focus trap so that keyboard users can effectively navigate (and close) the carousel.

Proposed changes:

  • Removes the tabindex and aria label from images, this created an extra tab stop and prevented the images' alt text from being read
  • Ensure all images with carousels are wrapped in links† so that they are focusable and interactive, without creating additional tab stops.
  • Insert a .screen-reader-text span into the link, which will indicate the button's action without overwriting the alt text on the image
  • Moves focus onto the overlay container when the carousel is open, so that the next interactive element is the close button
  • Moves the button up in the carousel source order so that it's first in tab order (before the slide arrows)
  • Sets up a focus trap so that tabbing while the carousel is open cycles through the elements on screen, nothing behind the carousel
  • Moves focus back to the opening image when the carousel closes‡
  • Adds any alt text to the slide image for screen readers

† These are already in links, generally, so for compatibility I stayed with links, with role=button to indicate correct keyboard interactions.

‡ This works great in "normal" cases where someone opens and closes an image, but there's an edge case if the page reloads with carousel open. If a page has the same image multiple times and is reloaded, on close it will focus back to the first instance of the photo. In general I think the focus improvement is worth this, but I'm open to feedback.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Does this pull request change what data or activity we track or use?

No

Testing instructions:

  1. Check that Carousel is enabled in Jetpack > Settings > Writing tab > Media section
  2. Find or create posts with images, a gallery, a tiled gallery block, and/or gallery shortcode (this works, but it's not pretty 😆)
  3. For image blocks, make sure the Link is set to "Attachment page"; gallery blocks use carousel regardless of selection (including none, see Images in Gallery Blocks remain clickable when settings set to "Link to None" #28030)
  4. View the post on the frontend
  5. Click your images, you should see the carousel
  6. Tab through the page
  7. Each image should be only one tab stop (the link wrapper)
  8. Hit space or enter, the carousel should open
  9. Hit tab once, it should focus the close button
  10. Tab a few times, it should cycle through the buttons on screen (you should be able to visually follow the focus with the outline)
  11. Hit enter or space on the close button, it should close the carousel
  12. Focus is back on the image you started on, so you can continue tabbing through the page

Try running through the same steps with a screen reader, though it's a little janky, it is a better experience. The image alt text is actually read aloud now, and is included on the large image too.

Copy link
Contributor

github-actions bot commented Feb 27, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the update/carousel-accessibility branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/carousel-accessibility

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Feature] Carousel A fullscreen modal appearing when clicking on an image in a gallery or tiled gallery. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress labels Feb 27, 2025
Copy link
Contributor

github-actions bot commented Feb 27, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • 🔴 Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: March 4, 2025
    • Code freeze: March 3, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Feb 27, 2025
Copy link

jp-launch-control bot commented Feb 27, 2025

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/modules/carousel/jetpack-carousel.js 0/829 (0.00%) 0.00% 37 💔
projects/plugins/jetpack/modules/carousel/jetpack-carousel.php 54/616 (8.77%) -0.01% 1 ❤️‍🩹

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

Switch from overriding the image content to make items clickable to ensuring all images are wrapped in links, with additional context for screen readers.
@ryelle ryelle force-pushed the update/carousel-accessibility branch from af2e33a to a22e90c Compare February 28, 2025 20:21
@ryelle ryelle self-assigned this Feb 28, 2025
@ryelle ryelle removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Feb 28, 2025
@ryelle ryelle marked this pull request as ready for review February 28, 2025 21:27
@ryelle ryelle added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Feb 28, 2025
@github-actions github-actions bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Feb 28, 2025
@ryelle ryelle added the [Focus] Accessibility Improving usability for all users (a11y) label Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Carousel A fullscreen modal appearing when clicking on an image in a gallery or tiled gallery. [Focus] Accessibility Improving usability for all users (a11y) [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements.
Projects
None yet
1 participant