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

onEnter of transition component is fired when its child is set to v-show="false" #4845

Closed
07akioni opened this issue Oct 24, 2021 · 10 comments
Closed
Labels
has workaround A workaround has been found to avoid the problem need guidance The approach/solution in the PR is unclear and requires guidance from maintainer to proceed further. scope: transition

Comments

@07akioni
Copy link
Contributor

07akioni commented Oct 24, 2021

Version

3.2.20

Reproduction link

SFC Playground

Steps to reproduce

See the link

What is expected?

onEnter is not fired since v-show=false

What is actually happening?

onEnter is fired

@ygj6
Copy link
Member

ygj6 commented Oct 25, 2021

@posva
Copy link
Member

posva commented Oct 25, 2021

This behavior seems inconsistent with v-if, which can be used as a temporary workaround

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

Bigfish8 commented Oct 26, 2021

Maybe it is not a bug?
persisted is designed for this condition.
You should set persisted to true.

@07akioni
Copy link
Contributor Author

persisted

I can't understand what it behaves by reading the docs. I just want it have the same behavior on hooks like v-if.

@Bigfish8
Copy link
Contributor

It is Intentional?
Just in my option,v-show means element actually render.It seems reasonable if it trigger the enter hooks.

@posva posva added has workaround A workaround has been found to avoid the problem need guidance The approach/solution in the PR is unclear and requires guidance from maintainer to proceed further. and removed 🐞 bug Something isn't working ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. labels Oct 28, 2021
@07akioni
Copy link
Contributor Author

07akioni commented Oct 28, 2021

It is Intentional? Just in my option,v-show means element actually render.It seems reasonable if it trigger the enter hooks.

I don't think so. Enter is transition's enter, not the child element's enter.

@mehanalavimajd
Copy link
Contributor

@07akioni , I think you should delete the appear attribute from the transition because according to docs :

If you also want to apply a transition on the initial render of a node, you can add the appear

The element has rendered because v-show will just add an display:none to element and when you add the appear , the onEnter method will be fired.
So you can do 2 things to solve this problem :

  1. delete appear attribute
  2. change v-if to v-show (preferred way)

@07akioni
Copy link
Contributor Author

07akioni commented Nov 2, 2021

@07akioni , I think you should delete the appear attribute from the transition because according to docs :

If you also want to apply a transition on the initial render of a node, you can add the appear

The element has rendered because v-show will just add an display:none to element and when you add the appear , the onEnter method will be fired. So you can do 2 things to solve this problem :

  1. delete appear attribute
  2. change v-if to v-show (preferred way)

I want the animation play on its first mount.

@mehanalavimajd
Copy link
Contributor

mehanalavimajd commented Nov 2, 2021

I want the animation play on its first mount.

your description is really incomplete . if you want that animation play on its first mount , so what is the bug?

@07akioni
Copy link
Contributor Author

07akioni commented Nov 2, 2021

I want the animation play on its first mount.

your description is really incomplete . if you want that animation play on its first mount , so what is the bug?

When default v-show is set to true, everything works fine.

The main problem is when the default v-show is set to false, the animation done (onEnter) hook is still called.

This is inconsistent between v-show and v-if. I expect all the hooks should be fired in the same manner. There's no document clearly regulates the behavior.

iwusong pushed a commit to iwusong/core that referenced this issue May 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has workaround A workaround has been found to avoid the problem need guidance The approach/solution in the PR is unclear and requires guidance from maintainer to proceed further. scope: transition
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants