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

<TransitionGroup> not working with <PortalTarget> when <Portal> is component root in Vue 3 #396

Open
samueleiche opened this issue Apr 26, 2023 · 0 comments

Comments

@samueleiche
Copy link

Problem: When the <Portal> component is the root component in another component, then the transition is not applied when it is rendered. Here's representational code:

 // Modal.vue
<template>
	<Portal to="modals">
		<div class="modal" :key="id">
		     ...
		</div>
	</Portal>
</template>
 // Index.vue
<template>
    ....
    <PortalTarget name="modals" multiple>
        <template #wrapper="nodes">
            <TransitionGroup name="modal-transition">
                <Component v-for="node in nodes" :key="node.key" :is="node" />
            </TransitionGroup>
        </template>
    </PortalTarget>
</template>

Expected: When the modal is mounted, then I expect it to transition in and transition out when unmounted.

Actual: No transition is applied when the component is mounted/unmounted.

I found that by moving the <Portal> out of the component, the transitions starts working. But I wouldn't want to have this much repeated code.

 // SomeComponent.vue
<template>
	<Portal to="modals">
		<Modal v-if="show" />
	</Portal>
</template>

Reproduction: I made a Codepen with the not working transition. The working example is commented out as well.

Any help is appreciated!

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

1 participant