-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Teleport
component's DOM isn't unmounted when deactivated inside KeepAlive
#5603
Comments
Teleport
component isn't unmounted when deactivated inside KeepAlive
Teleport
component's DOM isn't unmounted when deactivated inside KeepAlive
I'm running into the same issue if the app is mounted to a specific element and then later that element is removed from the page. The entire app goes away correctly but the Teleported item that is disabled then displays and is left on the page |
I think this should be tagged as bug. |
Has anyone found a way to get around this problem? |
@xeleoss |
The workaround works! I wrote a component that uses it. FixedTeleport.vue<script setup lang="ts">
import { useActivated } from "@/composables/useActivated";
const props = defineProps({
to: String,
disabled: Boolean,
});
const isActivated = useActivated();
</script>
<template>
<Teleport :disabled="!isActivated || props.disabled" :to="props.to">
<slot />
</Teleport>
</template> useActivated.tsimport { onActivated, onDeactivated, ref } from "vue";
export function useActivated() {
const isActive = ref(true);
onActivated(() => {
isActive.value = true;
});
onDeactivated(() => {
isActive.value = false;
});
return isActive;
} |
Version
3.2.31
Reproduction link
codesandbox.io
Steps to reproduce
Click 'show modal' then click 'to tab2'.
What is expected?
Modal's DOM removed.
What is actually happening?
Modal's DOM isn't removed.
The text was updated successfully, but these errors were encountered: