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

Unhandled error during execution of scheduler flush when rendering components in a transition group that have a v-if directive #5168

Closed
adamreisnz opened this issue Dec 24, 2021 · 7 comments · Fixed by #9421
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 🐞 bug Something isn't working scope: transition

Comments

@adamreisnz
Copy link

adamreisnz commented Dec 24, 2021

Version

3.2.26

Reproduction link

sfc.vuejs.org/

Steps to reproduce

I am using a transition group as follows:

<transition-group name="foo" tag="div" appear>
...
</transition-group>

Within it, I have a list of custom components. If I apply a v-if on these components within the parent template, everything works as expected:

<transition-group name="foo" tag="div" appear>
  <other-component v-for="item in items"  :key="item.id" />
  <foo-component key="foo" :foos="foos" v-if="foos.length > 0" />
  <bar-component key="bar" :bars="bars" v-if="bars.length > 0" />
</transition-group>

Both foos and bars are loaded asynchronously, and the components appear correctly with a transition animation as soon as the items are loaded and available.

However, I tried to refactor this to letting the components load the items themselves, and if I move the v-if into the child component (still on the outer most HTML element), as follows:

<transition-group name="foo" tag="div" appear>
  <other-component v-for="item in items"  :key="item.id" />
  <!-- now these components load their items themselves, and govern their own appearance with an internal `v-if` -->
  <foo-component />
  <bar-component />
</transition-group>

This however triggers a series of errors in the console:

Unhandled error during execution of render function 
Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next 
TypeError: child.el.getBoundingClientRect is not a function

What is expected?

That if using a v-if inside of a child component which is listed in a transition-group, this works as expected.

What is actually happening?

The error as above is thrown and v-for some of the components in the transition group fail to render.


Trying to render components in a transition group and govern their appearance internally in the component instead of externally in the parent component.

To reproduce in the playground, remove the v-if condition on the Bar.vue component to make the example work, then put it back to trigger the error.

@adamreisnz adamreisnz changed the title Unhandled error during execution of scheduler flush Unhandled error during execution of scheduler flush when rendering components in a transition group that have a v-if directive Dec 24, 2021
@adamreisnz
Copy link
Author

The interesting thing is that this error only seems to occur if you have both the v-for rendered list of items, and the component with v-if together in the same transition group.

If you take either of them out, everything works as expected.

@adamreisnz
Copy link
Author

Further testing reveals that using v-show instead of v-if in the child components does not result in the same problem, so this is an acceptable workaround for now.

@LinusBorg LinusBorg added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 🐞 bug Something isn't working scope: transition has workaround A workaround has been found to avoid the problem labels Dec 25, 2021
@posva
Copy link
Member

posva commented Dec 26, 2021

@LinusBorg I don't think this is a bug: <transition-group> should have a child with v-for only, shouldn't it? Based on that, using transition + transition-group works fine

@LinusBorg
Copy link
Member

I don't think v-for is the problem. The problem is that when a transition-group updates (here: the v-for items where changed), one of the child elements is a component still that has a comment as a placeholder element because of a v-if inside it.

While TransitionGroup skips comment nodes from direct children (i.e. the div with the v-if in the transition-group, it fails to properly do so for a child component that itself renders a comment.

Now, we can talk about wether a component in a transition group must always have a root element, but I feel like there may be an actual fix.

@posva
Copy link
Member

posva commented Dec 26, 2021

Right, but that bar component shouldn’t go in the transition group, it should go in a transition and then it works

@adamreisnz
Copy link
Author

adamreisnz commented Dec 26, 2021 via email

@jballa1
Copy link

jballa1 commented Oct 8, 2022

I am having the same issue when working with Q-Table (Quasar). Because of this the table updates only first time and subsequent changes wont reflect throwing this issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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 🐞 bug Something isn't working scope: transition
Projects
None yet
4 participants