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

[BUG] AnimatePresence popLayout mode does not work within a shadow dom #2508

Open
disambiguator opened this issue Feb 6, 2024 · 5 comments · May be fixed by #2830
Open

[BUG] AnimatePresence popLayout mode does not work within a shadow dom #2508

disambiguator opened this issue Feb 6, 2024 · 5 comments · May be fixed by #2830
Labels
bug Something isn't working

Comments

@disambiguator
Copy link

Description

If we use AnimatePresence inside a shadow DOM, the popLayout features don't work. This is because we're unable to find the temporary styles added, because shadow dom won't apply styles found in document.head.

Code sandbox repro: https://codesandbox.io/p/sandbox/framer-motion-shadow-dom-f7gkk6?file=%2Fsrc%2FApp.js%3A89%2C2

4. Steps to reproduce

Steps to reproduce the behavior:

  1. Open the code sandbox link
  2. Click the example to run the animation. You'll notice the popLayout behavior is not occurring.
  3. Uncomment line 86, skipping the shadow DOM.
  4. popLayout starts working again.

Technical guess of the problem

From what I understand, popLayout works by applying a temporary class which positions an element as absolute during exit transition. This does not work in shadow DOMs due to the way the style is applied. I think the code here is adding the temporary class, but it's hardcoded to using document.head, which won't be available to the shadow dom.

@disambiguator disambiguator added the bug Something isn't working label Feb 6, 2024
@cymptom
Copy link

cymptom commented Sep 30, 2024

That guess at the cause seems likely :(

If anyone has a workaround for this issue, please share 🙏

@ParkerSm1th
Copy link

Wanted to bump this issue, currently experiencing it and would love to continue using framer motion in my project.

@rdamore2812
Copy link

Bump too. Would love any workaround!

@tehbelinda
Copy link

I made a PR to fix this: #2830, works if I pass in the shadowRoot directly.
Would appreciate any feedback!

@dylank
Copy link

dylank commented Oct 15, 2024

@mattgperry can you help get this merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants