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

feat(react): respect prefers-reduced-motion with Accordion #832

Merged
merged 11 commits into from
May 4, 2023

Conversation

tbusillo
Copy link
Contributor

@tbusillo tbusillo commented Nov 25, 2022

closes: #828

Summary

  • Adds utility for detecting whether a system has prefers-reduced-motion: reduce enabled.
  • If it is prefers-reduced-motion is enabled, the <Accordion> animations/transitions are disabled.
  • Unrelated , added a few basic properties to the prettier config in package.json. Was running into config issues/inconsistencies in things like trailing commas, parens, etc.

@github-actions
Copy link
Contributor

@tbusillo tbusillo changed the title feat(react): respect prefers-reduced-motion in Accordion feat(react): respect prefers-reduced-motion with Accordion Nov 25, 2022
@tbusillo tbusillo marked this pull request as ready for review November 25, 2022 12:20
@tbusillo tbusillo requested a review from a team as a code owner November 25, 2022 12:20
Copy link
Member

@scurker scurker left a comment

Choose a reason for hiding this comment

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

The bulk of the animation happens inside of ExpandCollapsePanel in the animateOpen/animateClose functions. I would think we would instead want to be sure our reduced motion handling code happens there instead of Accordion.

Additionally, I think you were close to the right idea of adding the reduce-motion media query in both spots, but we should be very specific with what we're targeting. For example:

@media (prefers-reduced-motion: reduce) {
  .ExpandCollapse__panel {
    animation: none !important;
  }
}

Targeting ExpandCollapseComponent I think is better because it's the component that's actually controlling the animation and is composed with the Accordion component. Also we can safely use !important here because we always want the animation of the section to be turned if there's more specific/cascading selectors.

@CharlesBelov
Copy link

CharlesBelov commented May 2, 2023

@scurker : re: "I'm not sure we need prefers-reduced-motion here. Setting this value doesn't mean "no motion", but removing non-essential motion. I would argue that the slight motion that happens here (the rotation of caret and the highlight of the trigger) are still subtile enough where it isn't needed."

There is some confusion around prefers-reduced-motion. First, the name is a historical artifact of what Apple called it when it created the feature, "Reduce motion". Windows calls it "show animation in windows" and Android uses a similar all-or-nothing label. Second, there are at least a couple conditions which are addressed by this setting: vestibular motion disorders (the motion makes the viewer feel ill) and hypervigilance (the motion attracts the attention of the viewer out of proportion to its importance); further, even if the animation on your website or application is safe, past disruption from other sites' excessive animation can cause any un-requested animation to be triggering. Any of this can disrupt the end-user. This makes it difficult to determine a safe amount of animation which will serve everyone implementing this non-granular setting on their operating system. A choice of no animation is the safest.

That said, "the slight motion that happens here (the rotation of caret and the highlight of the trigger)" is probably sufficiently subtle.

@bobbyomari : re: "From a user experience perspective, the accordion animation can also be helpful for users to notice the change of content and what is occurring on the screen."

People for whom the accordion animation would be helpful would be unlikely to set prefers-reduce-motion to reduce. I set prefers-reduced-motion to reduce because the motion pretty much always distracts me, sometimes makes my eyes feel ill for up to half an hour afterwards, and I have been triggered by animation which would otherwise be safe for me because of past experiences with excessive animation.

@tbusillo tbusillo requested a review from a team as a code owner May 4, 2023 13:25
@tbusillo tbusillo requested a review from scurker May 4, 2023 13:35
@tbusillo
Copy link
Contributor Author

tbusillo commented May 4, 2023

Looks like was able to accomplish pretty much everything via the css media query and simplified everything as a result.

@CharlesBelov would you be willing/interested to take a look at the preview and let us know what you think? The two components likely relevant are the Accordion and the Expand Collapse Panel. We're looking to get this into an upcoming release, so any feedback you have would be greatly valued!

@tbusillo tbusillo enabled auto-merge (squash) May 4, 2023 15:30
@tbusillo tbusillo merged commit 9f1a3f9 into develop May 4, 2023
@tbusillo tbusillo deleted the expand-collapse-prefer-reduced-motion branch May 4, 2023 15:34
@scurker
Copy link
Member

scurker commented May 4, 2023

I created #1062 to make the UI immediately responsive, but this addresses the immediate accessible need.

@github-actions
Copy link
Contributor

github-actions bot commented May 4, 2023

@CharlesBelov
Copy link

@tbusillo Thank you for the fast follow up. I would be happy to take a look at the preview; however I am not knowledgeable about dealing with pull requests on github. When I go to those pages that you have linked, for example, https://expand-collapse-prefer-reduced-motion.d1gko6en628vir.amplifyapp.com/, I get a blank page, and Firefox's network inspector says "no requests".

@tbusillo
Copy link
Contributor Author

tbusillo commented May 4, 2023

@CharlesBelov Ah, it looks like the link(s) expired when the PR was merged. Here are some new ones!

Accordion: https://cauldron.dequelabs.com/components/Accordion

Expand Collapse Panel: https://cauldron.dequelabs.com/components/ExpandCollapsePanel

Thank you for being willing to take a look!

@CharlesBelov
Copy link

Yes, thank you! That is exactly what I expect to happen with prefers-reduced-motion enabled on my operating system.

@scurker
Copy link
Member

scurker commented May 4, 2023

@CharlesBelov This will likely land in the axe extension with the next update (which normally happens around every ~2 weeks) so keep a lookout for that release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accordion should respect prefers-reduced-motion
4 participants