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

Child component attribute updates break when using a transition component inside a teleport component #4161

Closed
andrewcourtice opened this issue Jul 20, 2021 · 5 comments
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

Comments

@andrewcourtice
Copy link

andrewcourtice commented Jul 20, 2021

Version

3.1.5

Reproduction link

SFC Playground Reproduction

Steps to reproduce

  1. Toggle the Enable Class checkbox to turn the class on and off. Note the child component content background is not turning red.
  2. Untick the Transition? checkbox.
  3. Repeat step 1 and note the child component content background is turning red.

What is expected?

The child component should have the .some-class class applied to it when used inside a transition in a teleport component.

What is actually happening?

The class is not being applied


This was working in v3.1.3 however I can't select v3.1.3 to reproduce a working version in the SFC playground as there appears to be an API change between v3.1.3 and v3.1.5 which breaks the demo.

@andrewcourtice andrewcourtice changed the title Child component renders break when using a transition component inside a teleport component Child component attribute updates break when using a transition component inside a teleport component Jul 20, 2021
@andrewcourtice
Copy link
Author

This may be related to #4155

@posva posva added 🐞 bug Something isn't working ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. scope: transition and removed 🐞 bug Something isn't working ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. labels Jul 21, 2021
@posva
Copy link
Member

posva commented Jul 21, 2021

attrs is not reactive but it should be usable in the template. I think this is a bug but I'm not completely sure

@posva posva added 🐞 bug Something isn't working need guidance The approach/solution in the PR is unclear and requires guidance from maintainer to proceed further. labels Jul 21, 2021
@edison1105
Copy link
Member

without teleport also has same problem, see playground

@yyx990803
Copy link
Member

yyx990803 commented Jul 21, 2021

This is a bug specific to useAttrs. For now you can simply bind to $attrs directly in the template.

It's also not teleport or transition related. Any component that renders default slot can lead to this behavior.

@yyx990803 yyx990803 added 🔨 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 and removed scope: transition need guidance The approach/solution in the PR is unclear and requires guidance from maintainer to proceed further. labels Jul 21, 2021
@andrewcourtice
Copy link
Author

andrewcourtice commented Jul 21, 2021

@yyx990803 Thanks for sorting those out so quickly! That's great!

I have a few lingering questions regarding this though.

To give you a bit of context, the reason this has become an issue for me is because I have a composition that splits the attrs object in a higher-order component with inheritAttrs: false so that specific subsets of attributes can be redirected to different child components (ie. onBeforeEnter to a Transition and class to a div or something like that). Here's an SFC playground example of what I am trying to achieve.

Previously this worked by using a customRef. After the latest fix I can achieve the same result using an object with getters that point back to the original attrs object and a __vInternal: 1 flag to notify Vue to update. Here's a working SFC playground example

As far as I am aware it is quite a common use-case to redirect subsets of attributes from higher-order components to different parts of the template. In light of this, I am curious as to the following:

  1. Is my approach to splitting the attrs object completely nuts and, if so, is there a better alternative that doesn't rely on using internal flags like __vInternal: 1?
  2. In your experience is this a common use-case among other devs working on medium-large Vue codebases?
  3. If 2 is true, would it be reasonable to request an official splitAttrs API shipped with Vue to perform these operations?

Thanks again for looking into this.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2023
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
Projects
None yet
Development

No branches or pull requests

4 participants