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

Add support for AnimatePresence when using shadow DOM #2830

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

tehbelinda
Copy link

@tehbelinda tehbelinda commented Oct 11, 2024

By default this was using document.head, but that is not always available to where it's rendered, e.g. when using the shadow DOM. In such cases, this change allows for the shadow root to be passed to the new parentDOM prop. This change is backwards compatible since we default to document.head when not specified.

Fixes #2508

@tehbelinda tehbelinda force-pushed the tehbelinda/animate-poplayout-shadowdom branch 2 times, most recently from 58d608b to 88dd5de Compare October 22, 2024 20:27
@dylank
Copy link

dylank commented Oct 24, 2024

Hey @mattgperry, do you know what the process is to get this change merged?

@tehbelinda tehbelinda force-pushed the tehbelinda/animate-poplayout-shadowdom branch from 88dd5de to 8443249 Compare October 25, 2024 17:10
…esence with mode === `popLayout`

By default this was using document.head, but that is not always available to where it's rendered,
e.g. when using the shadow DOM. Instead, pass the shadow root to the new `parentDOM` prop
@tehbelinda tehbelinda force-pushed the tehbelinda/animate-poplayout-shadowdom branch from 8443249 to c1f485c Compare October 26, 2024 14:37
@tehbelinda
Copy link
Author

hi @mattgperry the pipeline is passing and I just updated the latest conflicts on the CHANGELOG, let me know if you are able to review and approve this or is there someone else I should ping? thanks!

@dylank
Copy link

dylank commented Nov 11, 2024

@kurtextrem is this something you can help with?

@tehbelinda tehbelinda changed the title Add custom DOM prop for styles when using AnimatePresence with mode === popLayout Add support for AnimatePresence when using shadow DOM Nov 11, 2024
@connormdavis
Copy link

@SaeWooKKang @mattgperry this is a blocker for me would be huge to get this merged 🙏

@kurtextrem
Copy link
Contributor

Hey! I had a brief look, it looks good to me. I've forwarded the PR.

@@ -346,6 +346,39 @@ describe("AnimatePresence", () => {
return await expect(promise).resolves.toBe(3)
})

test("Can cycle through multiple components with mode === 'popLayout' and dom", async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not 100% on what this test is trying to achieve.

Is it more expected based on the changes that we should check that style blocks are being correctly added to the testDom elements?

Copy link
Collaborator

@mattgperry mattgperry 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!

It would be good to duplicate packages/framer-motion/cypress/integration/animate-presence-pop.ts and the animate-presence-pop and dev/react/src/tests/animate-presence-pop, and rerunning all the tests in a situation that uses a new ShadowRoot.

Additionally, do we expect other elements to be used other than ShadowRoot? It feels to me like shadowRoot or root might be a more indicative prop name.

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.

[BUG] AnimatePresence popLayout mode does not work within a shadow dom
5 participants