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

[Challenging Bug] Teleport cumulates its content when used with Suspense #4183

Closed
dmx974 opened this issue Jul 24, 2021 · 1 comment
Closed
Labels
🐞 bug Something isn't working scope: suspense

Comments

@dmx974
Copy link

dmx974 commented Jul 24, 2021

Version

vue 3.1.4

Reproduction link

https://github.com/dmx374/teleportbug

Steps to reproduce

If you have 2 layouts (LayoutA.vue, LayoutB.vue, see the reproduction repo) and one is using Suspense, then teleport cumulates its content instead of cleaning.

When you go back and forth between Index and About pages, multiple times (go to About, then Index, then About again and so on), the #modal target get cumulated.

To fix the bug:

  • open LayoutA.vue
  • remove the Suspense tag, replace with slot (like in LayoutB.vue)

What is expected?

Teleport should not cumulate its content. Remove Suspense in LayoutA (put slot instead) to see the expected normal behavior.

What is actually happening?

Teleport is cumulating things when using with Suspense

@edison1105
Copy link
Member

edison1105 commented Jul 24, 2021

mini repro see playground

cause is :

function normalizeSuspenseSlot(s: any) {
  //...
  s = normalizeVNode(s)
  if (block) {
+	after filter, dynamicChildren is an empty array.maybe should avoid set an empty array to dynamicChildren 
    s.dynamicChildren = block.filter(c => c !== s)
  }
  return s
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐞 bug Something isn't working scope: suspense
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants