diff --git a/packages/vuetify/src/components/VSelect/VSelect.tsx b/packages/vuetify/src/components/VSelect/VSelect.tsx index 449ad3fed2f..ef7ce95d8b9 100644 --- a/packages/vuetify/src/components/VSelect/VSelect.tsx +++ b/packages/vuetify/src/components/VSelect/VSelect.tsx @@ -176,7 +176,7 @@ export const VSelect = genericComponent { 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 }) diff --git a/packages/vuetify/src/components/VSelect/__tests__/VSelect.spec.cy.tsx b/packages/vuetify/src/components/VSelect/__tests__/VSelect.spec.cy.tsx index b438127a98a..fd60cd9c537 100644 --- a/packages/vuetify/src/components/VSelect/__tests__/VSelect.spec.cy.tsx +++ b/packages/vuetify/src/components/VSelect/__tests__/VSelect.spec.cy.tsx @@ -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) => ( + + )).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