Skip to content

Commit d2a042b

Browse files
fix(VCombobox): don't add empty values (#13298)
fixes #13274
1 parent d285435 commit d2a042b

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

packages/vuetify/src/components/VCombobox/VCombobox.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ export default VAutocomplete.extend({
214214

215215
// If the user is not searching
216216
// and no menu item is selected
217+
// or if the search is empty
217218
// do nothing
218-
if (menuIndex < 0 &&
219-
!this.searchIsDirty
220-
) return
219+
if ((menuIndex < 0 && !this.searchIsDirty) ||
220+
!this.internalSearch) return
221221

222222
if (this.editingIndex > -1) {
223223
return this.updateEditing()

packages/vuetify/src/components/VCombobox/__tests__/VCombobox-multiple.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,4 +455,32 @@ describe('VCombobox.ts', () => {
455455
await wrapper.vm.$nextTick()
456456
expect(change).toHaveBeenLastCalledWith(['foo', 'bar'])
457457
})
458+
459+
// https://github.com/vuetifyjs/vuetify/issues/13274
460+
it('should not add empty values', async () => {
461+
const { wrapper, change } = createMultipleCombobox({
462+
chips: true,
463+
multiple: true,
464+
items: ['foo'],
465+
value: ['foo'],
466+
})
467+
468+
const input = wrapper.find('input')
469+
const element = input.element as HTMLInputElement
470+
471+
// Add a value and then remove it
472+
input.trigger('focus')
473+
element.value = 'a'
474+
input.trigger('input')
475+
await wrapper.vm.$nextTick()
476+
element.value = ''
477+
input.trigger('input')
478+
await wrapper.vm.$nextTick()
479+
480+
// Lose focus
481+
input.trigger('keydown.tab')
482+
await wrapper.vm.$nextTick()
483+
484+
expect(change).not.toHaveBeenCalled()
485+
})
458486
})

0 commit comments

Comments
 (0)