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

A11y: Update animation/transition styles with reduced motion media queries #68315

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

Conversation

himanshupathak95
Copy link
Contributor

@himanshupathak95 himanshupathak95 commented Dec 26, 2024

Part of: #68282

What?

Refactors animation and transition styles to use @media not (prefers-reduced-motion) ensuring better accessibility for users who prefer reduced motion.

Why?

Currently, many places in the codebase do not account for user's motion preferences. This might not be correct for user's having reduced motion preferences. This PR fixes that.

Testing Instructions

  1. Open the Block Editor

  2. Add an Image block and upload an image

  3. Enable the lightbox feature in block settings

  4. Test normal behavior:

    • Click to open Lightbox
    • Observe opening/closing animations
    • Test zoom functionality
  5. Test with reduced motion preference:

    • Enable "Reduced motion" preference:
      • Chrome DevTools: Open DevTools > More Tools > Rendering > "Emulate CSS media feature prefers-reduced-motion" > select "reduce"
    • Repeat the above tests
    • Verify that:
      • Lightbox opens/closes without animation
      • No zoom animations occur
  6. Disable reduced motion and verify all original animations work correctly

Screencast

Screen.Recording.2024-12-26.at.15.53.49.mov

@himanshupathak95 himanshupathak95 marked this pull request as ready for review December 26, 2024 11:30
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: himanshupathak95 <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@himanshupathak95
Copy link
Contributor Author

Hey @t-hamano!

Updated the animation handling to follow user preferences. Let me know if this is what you had in mind. Thanks!

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Block library /packages/block-library labels Dec 27, 2024
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Two pieces of feedback from me:

  • It would be better to use @media not ( prefers-reduced-motion ) instead of @media (prefers-reduced-motion: no-preference). See this comment. Furthermore, it would be good if you could update existing @media (prefers-reduced-motion: no-preference).
  • Does this PR only target the Image block? Or does it target the @wordpress/block-library? If it is the latter, it would be good to check other blocks as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants