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(VSelect): fix hide-selected with return-object #19807

Merged
merged 1 commit into from
May 14, 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/vuetify/src/components/VSelect/VSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export const VSelect = genericComponent<new <

const displayItems = computed(() => {
if (props.hideSelected) {
return items.value.filter(item => !model.value.some(s => s === item))
return items.value.filter(item => !model.value.some(s => props.valueComparator(s, item)))
}
return items.value
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,44 @@ describe('VSelect', () => {
cy.get('.v-overlay__content .v-list-item .v-list-item-title').eq(0).should('have.text', 'Item 3')
cy.get('.v-overlay__content .v-list-item .v-list-item-title').eq(1).should('have.text', 'Item 4')
})

// https://github.com/vuetifyjs/vuetify/issues/19806
it('should hide selected item(s) with return-object', () => {
const selectedItem = ref({ text: 'Item 1', id: 'item1' })
const items = ref([
{
text: 'Item 1',
id: 'item1',
},
{
text: 'Item 2',
id: 'item2',
},
{
text: 'Item 3',
id: 'item3',
},
])
cy.mount((props: any) => (
<VSelect
v-model={ selectedItem.value }
hideSelected
items={ items.value }
item-title="text"
item-value="id"
returnObject
/>
)).get('.v-select').click()
.get('.v-list-item--active').should('have.length', 0)
.get('.v-overlay__content .v-list-item').should('have.length', 2)
.get('.v-overlay__content .v-list-item .v-list-item-title').eq(0).should('have.text', 'Item 2')
.get('.v-overlay__content .v-list-item').eq(0).click({ waitForAnimations: false }).should(() => {
expect(selectedItem.value).to.deep.equal({ text: 'Item 2', id: 'item2' })
})
.get('.v-list-item--active').should('have.length', 0)
.get('.v-overlay__content .v-list-item').should('have.length', 2)
.get('.v-overlay__content .v-list-item .v-list-item-title').eq(0).should('have.text', 'Item 1')
})
})

// https://github.com/vuetifyjs/vuetify/issues/16055
Expand Down
Loading