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

fix(VTabs): render tabs correctly using items #19868

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/api-generator/src/locale/en/VTabs.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"height": "Sets the height of the tabs bar.",
"hideSlider": "Hide's the generated `v-tabs-slider`.",
"iconsAndText": "Will stack icon and text vertically.",
"items": "The items to display in the component. This can be an array of strings or objects with a property `title`.",
"items": "The items to display in the component. This can be an array of strings or objects with a property `text`.",
"light": "Applies the light theme variant to the component.",
"mobileBreakpoint": "Sets the designated mobile breakpoint for the component.",
"optional": "Does not require an active item. Useful when using `v-tab` as a `router-link`.",
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VTabs/VTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const VTabs = genericComponent<VTabsSlots>()({
key={ item.text }
value={ item.value }
v-slots={{
default: () => slots[`tab.${item.value}`]?.({ item }),
default: slots[`tab.${item.value}`] ? () => slots[`tab.${item.value}`]?.({ item }) : undefined,
}}
/>
)
Expand Down
13 changes: 13 additions & 0 deletions packages/vuetify/src/components/VTabs/__tests__/VTabs.spec.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,17 @@ describe('VTabs', () => {
expect(model.value).to.equal('B')
})
})

it('should render tabs using items', () => {
const items = [
{ text: 'A', value: 1 },
{ text: 'B', value: 2 },
{ text: 'C', value: 3 },
]
cy.mount(() => (
<VTabs items={ items } />
)).get('.v-tab').eq(0).should('have.text', 'A')
.get('.v-tab').eq(1).should('have.text', 'B')
.get('.v-tab').eq(2).should('have.text', 'C')
})
})
Loading