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

[Teleport] - Updating component inside Teleport causes HMR to crash #12816

Open
nunoraposo33 opened this issue Feb 6, 2025 · 1 comment · May be fixed by #12819
Open

[Teleport] - Updating component inside Teleport causes HMR to crash #12816

nunoraposo33 opened this issue Feb 6, 2025 · 1 comment · May be fixed by #12819
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has workaround A workaround has been found to avoid the problem scope: hmr

Comments

@nunoraposo33
Copy link

nunoraposo33 commented Feb 6, 2025

Vue version

3.5.13

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-grzg8vpe?file=src%2FApp.vue

Steps to reproduce

In App.vue update the slot content to anything else.
Also happens if you change the "Modal.vue", as an example change the class "modal__dialogs" to "modal_potatos".

In the browser's console it shows:
TypeError: Cannot set properties of null (setting '__vnode')

It's related to reactivity inside the component Modal.vue, in the computed "modalClasses", remove the reference to the ref "isVisible" and the error will not happen, or if the value of "isVisible" is set as "true" (line 16).

// Not sure if the title is accurate

What is expected?

I expect the modal component's hot reload to work normally.

What is actually happening?

Hot reload stops working after the error, need to refresh the page.

System Info

Using the stackblitz stack.

Any additional comments?

No response

@edison1105 edison1105 added scope: hmr 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Feb 7, 2025
@nunoraposo33
Copy link
Author

nunoraposo33 commented Feb 10, 2025

Thank you, as a temporary workarround you can just create a wrapper arround <Teleport>

// TeleportWrapper.vue

<script setup lang="ts"> 
import { computed } from "vue" 
 
const props = defineProps<{ 
    to: string | HTMLElement | null 
    disabled?: boolean 
}>() 
 
const teleportTarget = computed(() => (props.to ?? "body")) 
</script> 
<template> 
<teleport :to="teleportTarget"> 
  <slot /> 
</teleport> 
</template> 

And use <TeleportWrapper> instead of <Teleport>

@edison1105 edison1105 added the has workaround A workaround has been found to avoid the problem label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has workaround A workaround has been found to avoid the problem scope: hmr
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants