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

[Help] Usage with framer-motion #331

Closed
kylemh opened this issue Sep 16, 2021 · 5 comments
Closed

[Help] Usage with framer-motion #331

kylemh opened this issue Sep 16, 2021 · 5 comments

Comments

@kylemh
Copy link

kylemh commented Sep 16, 2021

I'd like to add animations to an AccordionItemPanel content as it is unexpanded, but it doesn't seem like <AnimatePresence> is able to intercept the unmounting.

Am I doing something wrong?

https://codesandbox.io/s/sharp-lichterman-io2mv?file=/src/App.tsx

@mikeebee
Copy link

@kylemh I tweaked your Codesandbox slightly to get it working. Just a little CSS hack to stop the display: none hiding the panel immediately. This may affect accessibility in that you might be able to focus on focusable items inside the hidden panels so investigate that if you need to.

https://codesandbox.io/s/youthful-fermi-vyy7u?file=/src/App.tsx

@kylemh
Copy link
Author

kylemh commented Sep 22, 2021

Got it. Added a link into the content and I see that's focusable even when the accordion is collapsed. I can probably create a component for the inner AccordionItemPanel content which leverages usePresence to switch the content to display: 'none' upon animation completion; however, this wouldn't prevent somebody from navigating into that content during the animation.

That's for me to figure out. Thank you!

@kylemh kylemh closed this as completed Sep 22, 2021
@mikeebee
Copy link

Ok cool! Post your update if you can, I wouldn't mind using it if it works well 😀

@kylemh
Copy link
Author

kylemh commented Sep 24, 2021

Unfortunately, I couldn't think of a solution that is both accessible and allows for exit animations. I believe it's a shortcoming of the API.

Instead, I've opted to replace react-accessible-accordion with @radix-ui/react-accordion

@mikeebee
Copy link

mikeebee commented Sep 25, 2021

@kylemh no worries, thanks for showing me the alternative you found, looks great!

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

No branches or pull requests

2 participants