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

TabItem Does Not Obey Ordering with v-for and key #1387

Closed
Skinner927 opened this issue May 8, 2019 · 2 comments
Closed

TabItem Does Not Obey Ordering with v-for and key #1387

Skinner927 opened this issue May 8, 2019 · 2 comments

Comments

@Skinner927
Copy link

Overview of the problem

Buefy version: v0.7.5
Vuejs version: v2.6.10
OS/Browser: MacOS 10.14.4/Chrome 73.0.3683.103

Description

When using v-for with key on b-tab-item the order of the tabs is incorrect if items are removed and added back.

Steps to reproduce

I've made a demo: https://codepen.io/Skinner927/pen/vwNYLp

  1. Observe the proper sorted order of the tabs: "April, Bob, Stan".
  2. Click the "Remove Bob" button
  3. Click the "Add Bob Back" button
  4. Observe the order of the tabs is now "April, Stan, Bob" which is incorrect. The ul list (at the top under "Sorted:") uses the same key mechanism and is properly sorted.

Expected behavior

For the order of tabs to be in the same order as the underlying array.

Actual behavior

Because v-for is only adding the missing elements, b-tab-item's created() method always appends new items to the end of the tab list.

@service-paradis
Copy link
Collaborator

service-paradis commented Jul 8, 2019

We get the same thing if we use v-if on tab-item. Even if the Books tab is before Videos, it will be displayed at the end when showing it.

ex.
https://codepen.io/service-paradis/pen/LYPQozm?&editable=true&editors=101

I'm working on it right now. I'm doing some tests, but should be able to make a PR tomorrow!

service-paradis added a commit to service-paradis/buefy that referenced this issue Jul 9, 2019
Add a fix to keep defined slots position for tabs
@service-paradis
Copy link
Collaborator

Created a PR that should solve this problem (#1535)

service-paradis added a commit to service-paradis/buefy that referenced this issue Dec 17, 2019
Add a fix to keep defined slots position for tabs
@jtommy jtommy closed this as completed in cf8a4c3 Dec 18, 2019
LeoMouyna pushed a commit to LeoMouyna/buefy that referenced this issue Jan 6, 2020
LeoMouyna pushed a commit to LeoMouyna/buefy that referenced this issue Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants