vuejs / core

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
https://vuejs.org/
MIT License
47.7k stars 8.33k forks source link

Issue in Transition between Components with the built-in Component tag if component root element has animation #11846

Closed Yejneshwar closed 2 months ago

Yejneshwar commented 2 months ago

Vue version

3.5.3

Link to minimal reproduction

https://play.vuejs.org/#eNrNV9tu2zgQ/RWuFoEdwJIv8qWrdYPNFkEvD2nRFn2p+0BLtMNaFgWScpIa+fcOh7pYthP0IgOVg5AcHs4cjsnR8da5TFNvkzEncKaardOYanYxSwiZRnyDnVoXBvNMa5GQjbsQ8vnMaW84u+0QnkTs7hwaYsZq5gBgDsZgxe4BhdNoFEkQxjxcgTGMV227buZcbLdmoae5jtnDw7RrwxQMugWFqZY0UVxzoJDQNQM3CxoxcL0WkRmJTLs8gTFNU0ZlxTsU61QkLNEk4MpEz6SE0SeICuic547xtaV8Me2WK0s2FQlLKqcHE1UKpyqUPDVrOCyXmrwAN32ykGJNWl4XRybzrRpgUAMMDgF+DeAfAoY1wPAQMKoBRoeAcQ0wPgRMaoBJDpgl7A4hEVvQLNZka3JTJk8FW9xzx+7TNr5thrYZ2WZsm8lDxziIqKbtc+uMEMl0JpNiBO6rLywgLQzQwmV7k/htBqRXzuExDT4XQ/uUbqsHD2Sw77l65jRcLaXI4Ki35jEMIBO783YTPxpicPoQ/ulDDE8fYnT6EOPTh5j8Uohq+MV20WIjr5m+ERHcNTtTldiSiL7hytu5GeS5NeGF+IzgL7YM7zqfJfA37ZY1DcveX65LXry6vnx5RVyXQoWgpiS6mq8ZGLAG6vvYFMNACqGRwj4wIP2J+hfde6ZWFBnbyQKJeQKl3F1KGnFg3R4MehFbdsjf83/MBzoLfM7BT32tq/g3COH3emf47xCQClvIoTYAogC4t2y+4rriGpDLonsNrx2yobK9v5Vzwqhi8A5c8IRrVrhai29N+PlNF5Df/4pdwbtuIWGp2vOUp753tj2WoGfPzmAqP32jR0B9/4z0IdE5zHSfdoa8TIr+NFJ/GB/PyBwXTj+TLg013zC479YYM7phudHSq/RJQGgck543Ungi7EGoezPv8j1fWlg/IqUh1/dwN+xCKAD5hXY6jlahgPO19L4qkYB+xBUgoeAS85jJt6mJD0owKFI2c4CLuH2DNi0zswNrD29YuDpi/6pAgQXQeSeZYnIDOq+c01QumbbTVx+u2R30y0kQgxkUsKcm3zMl4sxwtLD/IfVAeweHbF+j7OHJ8qO6utMM0ppvyhCt6u7MARFkSvpjW6/o+t6wKKmQxVIHHlXgUMCpQrUKMBCj1ptZQ/qPKs9SexLEH1NlBMVzqZhyPjv1PWeGAtQwyx0qkF8pSOKd98BPkR40RnrwOGkUxQ2S9hsj7R8hbT45cRTrDRLHc9YI8eFR4jlt/AnRIO1RY7RHT+cbf9o0SHzcGPHx08TxJ1eDxCeNEZ8cu5YP3wEFNjFp

Steps to reproduce

please change "--animation-time: 17s;" to any value to evaluate the issue. Use buttons Comp[1-7] to switch between components.

What is expected?

Transition should behave as it should when "animation" css property not present.

What is actually happening?

Vue takes as long as the specified "--animation-time" property to remove the transitioning element from the DOM

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 Intel(R) Core(TM) i7-6850K CPU @ 3.60GHz
    Memory: 15.01 GB / 31.91 GB
  Binaries:
    Node: 18.20.4 - C:\Program Files\nodejs\node.EXE      
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD        
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.4355
  npmPackages:
    vue: ^3.5.3 => 3.5.3

Any additional comments?

Using transitions with the built-in <component> tag while the root element of the components has an animation css property produces the issue. Removing the animation css property fixes the issue.

LinusBorg commented 2 months ago

I think you need to set the type prop on the <Transition> to let it know which type's duration it should wair for: transition or animation.

Docs: https://vuejs.org/api/built-in-components.html#transition

Playground:

https://play.vuejs.org/#eNrNV9tu2zgQ/RWuFoEdwJIv8qWrdYPNFkEvD2nRFn2p+0BLtMNaFgWScp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