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

[Bug Report] v-tab-item value is prefering index over value prop #10540

Closed
joelpro2 opened this issue Feb 11, 2020 · 26 comments · Fixed by #16383
Closed

[Bug Report] v-tab-item value is prefering index over value prop #10540

joelpro2 opened this issue Feb 11, 2020 · 26 comments · Fixed by #16383
Assignees
Labels
C: VTabs VTabs T: bug Functionality that does not work as intended/expected

Comments

@joelpro2
Copy link
Contributor

Environment

Vuetify Version: 2.2.11
Vue Version: 2.6.11
Browsers: Chrome 81.0.4044.9
OS: Windows 10

Steps to reproduce

use tab items with String value as explained in documentation https://vuetifyjs.com/en/components/tabs#tab-items

Expected Behavior

tab selected should match with the value prop

Actual Behavior

tabs use index instead even with value defined

Reproduction Link

https://codepen.io/joel_rodrigues/pen/poJJxEm?editors=1011

@ghost ghost added the S: triage label Feb 11, 2020
@nekosaur
Copy link
Member

Does it actually say that string value for value prop is supported? Am I missing it?

@joelpro2
Copy link
Contributor Author

joelpro2 commented Feb 20, 2020

API
<v-tab-item>
Name: Value
Type: Any
Default: Undefined
Description: Sets the value of the tab. If not provided, the index will be used.

<v-tabs-items>
Name: Value
Type: Any
Default: Undefined
Description: The designated model value for the component.

@nekosaur nekosaur added C: VTabs VTabs T: bug Functionality that does not work as intended/expected and removed S: triage labels Feb 20, 2020
@funkindy
Copy link

Same here, no ability to manage tabs with specific values, v-model only uses index.

@ananthachetan
Copy link
Contributor

ananthachetan commented May 8, 2020

Also the documentation for <v-tab> doesn't say anything about the value property.

@mr-amirganishaikh
Copy link

mr-amirganishaikh commented Jun 14, 2020

Not sure if it is the solution but it is working. This is also not present in documentation.

Keep :href with required value pre-pend it with # as below for v-tabs

<v-tabs v-model="activeItem" :show-arrows="false"> <v-tab v-for="(item, i) in items" :key="i" :href="'#'+item.value"> {{item.label}} </v-tab> </v-tabs>

Now set :value of v-tab-item with required key but don't mention # here

<v-tabs-items v-model="activeItem"> <v-tab-item v-for="(itemD, i) in items" :key="i" :value="itemD.value">Tab item for {{itemD.label}}</v-tab-item> </v-tabs-items>

Data used here is as below:
items: [{label: 'First', value: 'first', label: 'Second', value: 'second'}]

@wglas85
Copy link

wglas85 commented Jan 27, 2021

Please note, that v-list-item-group/v-list-item is the vertical component controlling v-tab-items/v-tab-item and v-list-item has a value property.
Hence, adding value to v-tag complements the API for the horizontal component controlling v-tab-items/v-tab-item to be in line with the vertical component.

@jakeflorentine
Copy link

I am still seeing this issue. The value of v-tab and v-tab-item seem to be ignored in favor of index still.

@ossicoinc
Copy link

This is still an issue. Workaround doesn't work if you aren't using v-tab-items / v-tab-item elements

@naiduyanda
Copy link

the value prop is not working with both v-tab and v-tab-item

@DurtyFree
Copy link

How can this be an issue after more than 2 years :( When dynamically handling whether tabs are rendered or not, index is not a reliable key :/

@styts

This comment was marked as spam.

@ryanrapini

This comment was marked as spam.

@BayBreezy

This comment was marked as spam.

@anandhanedom

This comment was marked as spam.

@joelpro2

This comment was marked as spam.

@alessandroAmedei

This comment was marked as spam.

nekosaur added a commit that referenced this issue Jan 5, 2023
@KaelWD KaelWD added this to the v2.7.0 (Nirvana) milestone Jan 12, 2023
@jornhd
Copy link

jornhd commented Jan 30, 2023

@joelpro2 If you replace :key="item.tab" with :href="'#${item.tab}'" (and replace ' here with `) in in your codepen https://codepen.io/joel_rodrigues/pen/poJJxEm?editors=1011, it will work as expected.

@joelpro2
Copy link
Contributor Author

joelpro2 commented Jan 31, 2023

@joelpro2 If you replace :key="item.tab" with :href="'#${item.tab}'" (and replace ' here with `) in in your codepen https://codepen.io/joel_rodrigues/pen/poJJxEm?editors=1011, it will work as expected.

That looks like a really bad workaround
key is a mandatory property when you're using v-for
And clearly not in Vuetify docs

@ViacheslavZyrianov

This comment was marked as spam.

@naiduyanda

This comment was marked as spam.

@ViacheslavZyrianov

This comment was marked as off-topic.

@jornhd
Copy link

jornhd commented Feb 21, 2023

@joelpro2 If you replace :key="item.tab" with :href="'#${item.tab}'" (and replace ' here with `) in in your codepen https://codepen.io/joel_rodrigues/pen/poJJxEm?editors=1011, it will work as expected.

That looks like a really bad workaround key is a mandatory property when you're using v-for And clearly not in Vuetify docs

Sorry, my bad. But if you add :href="'#' + item.tab" in <v-tab>, and not replacing anything, it will work.

@joelpro2
Copy link
Contributor Author

@joelpro2 If you replace :key="item.tab" with :href="'#${item.tab}'" (and replace ' here with `) in in your codepen https://codepen.io/joel_rodrigues/pen/poJJxEm?editors=1011, it will work as expected.

That looks like a really bad workaround key is a mandatory property when you're using v-for And clearly not in Vuetify docs

Sorry, my bad. But if you add :href="'#' + item.tab" in <v-tab>, and not replacing anything, it will work.

Still, you proposed the same workaround written in a different form.
I mean that this should be a internal behaviour, as mentioned in Vuetify Docs

@MathieuDerelle
Copy link

MathieuDerelle commented Mar 1, 2023

but using the :href="`#${item.tab}`" syntax changes the URL

I'd like to give a value to the tabs without changing the URL, how to do that ?

@craigrileyuk
Copy link

Did this fix ever get released? Can't see it in the v2-stable branch

@MathieuDerelle
Copy link

MathieuDerelle commented Nov 24, 2023

Did this fix ever get released? Can't see it in the v2-stable branch

it is in 2.7.1 at least (with the prop tab-value)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VTabs VTabs T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.