-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Transition-group animates only last element if using index as the key #8718
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
Comments
This is expected, the key controls how Vue reuses elements/components and is therefore crucial for transition-group. You can read more about it in the guide 🙂 |
I respect your time, so please understand that I didn't put this bug report up without looking for an answer first, so please be respectful of my time and don't be so dismissive. I found a new error as well during this search (see example at end). Search of documentation
I know this is unreasonable (usually) to ask, but I seriously looked through everything, even searching online, and found nothing on this topic. Can you provide a link to this documentation? Search results Index shows up 19 times on list rendering guide, but no mention of transitions. Index shows up 7 times on the API docs, none of the reference or are in context of the transition-group or transitions. Updated example with new error found: Instead of just the last item animating, the entire block fades in/out. (3rd example) |
Using the index as the key is the default behaviour. If you have propositions about notes to add to the docs, you should open a Pull Request with your proposal on the vuejs.org repository 🙂. Maybe a not on transition-group page is the right place Remember you can use the forum and the Discord server to get quick feedback on questions 🙂 |
From Vue's perspective, Let me give you an example: assume we have |
Thanks for the explanation, that certainly clears up why the errors are happening. But the results (which look like errors) are not documented anywhere that I could find, and if they are, not easily found.
I didn't even consider this idea, so I will do that. I've never done a PR before, so I hope I don't make more of a mess. Thanks guys. Edit: What about the error in the Vuejs.org cookbook? |
+1 Also experiencing this issue. Switched to different keys and it works. @megacromulent I've also never done a PR and would be interested in collaborating if you want a second pair of eyes. |
Hey, thanks for the offer. The only thing I would do is put documentation
in, I don't have the JS skills to contribute to a library like Vue.js.
Thanks for the offer though.
…On Wed, Oct 3, 2018 at 9:04 AM David Golden ***@***.***> wrote:
+1 Also experiencing this issue. Switched to different keys and it works.
@megacromulent <https://github.com/megacromulent> I've also never done a
PR and would be interested in collaborating if you want a second pair of
eyes.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8718 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AmYG171vJuPiQV9kv95mPhvyH3hzhOisks5uhMPQgaJpZM4WOkWp>
.
|
Was getting this issue as well. I'm creating a dynamic list where every new item added is blank and so there are multiple duplicates. Tried using the item as the key but get a warning not to use non-primitives. The v-move transition works on creation but not deletion of items. |
The pr #8748 doesn't give any explaination which seems not reasonable. The problem is that the |
+1. This needs to be represented by a unique key. At the same time, when the data changes, can you ensure that the key is still unique after re-rendering. |
Solution described in vuejs/vue#8718.
Uh oh!
There was an error while loading. Please reload this page.
Version
2.5.17
Reproduction link
https://codepen.io/megacromulent/pen/gdMYLx?editors=1010
Steps to reproduce
What is expected?
The item being removed/added should have the transition applied to it.
What is actually happening?
The last item in the list gets the transition applied.
This may be an old bug, as I was hunting for a solution to my problem, I ran into this from May 2017:
https://stackoverflow.com/questions/43598308/vue-js-wrong-transition-group-animation-position
If this is the intended behavior using index as the key, then can their be at least a warning message in the dev version of Vue.js to explain this? Or perhaps searchable text in the documentation with something like "only last item in list is animating/transition applied" so a solution can be found without thinking there is a bug in Vue.js.
The text was updated successfully, but these errors were encountered: