Skip to content

Transition-group animates only last element if using index as the key #8718

@megacromulent

Description

@megacromulent

Version

2.5.17

Reproduction link

https://codepen.io/megacromulent/pen/gdMYLx?editors=1010

Steps to reproduce

  1. Create vue app with items displaying in a list.
  2. Add transition group with v-for with format like v-for="(item, index) in items"
  3. Use "index" from v-for as the v-bind:key (like: v-bind:key="index" )
  4. Add and remove items from the data.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions