Skip to content

Commit

Permalink
fix(VAutocomplete/VCombobox): reset search when selecting same item
Browse files Browse the repository at this point in the history
fixes #7259
  • Loading branch information
johnleider committed Aug 7, 2019
1 parent 90b3960 commit eab8d32
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ export default VSelect.extend({
// instead activate the menu
this.activateMenu()
},
selectItem (item: object) {
VSelect.options.methods.selectItem.call(this, item)
this.setSearch()
},
setSelectedItems () {
VSelect.options.methods.setSelectedItems.call(this)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,34 @@ describe('VAutocomplete.ts', () => {

expect(inputSlot.element.getAttribute('role')).toBe('combobox')
})

// https://github.com/vuetifyjs/vuetify/issues/7259
it('should update search when same item is selected', async () => {
const wrapper = mountFunction({
propsData: {
items: ['foo'],
value: 'foo',
},
})

await wrapper.vm.$nextTick()

const input = wrapper.find('input')
const element = input.element as HTMLInputElement

expect(element.value).toBe('foo')

input.trigger('focus')
input.trigger('click')
element.value = 'fo'
input.trigger('input')

const item = wrapper.find('.v-list-item')

item.trigger('click')

await wrapper.vm.$nextTick()

expect(element.value).toBe('foo')
})
})
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VCombobox/VCombobox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default VAutocomplete.extend({
if (this.editingIndex > -1) {
this.updateEditing()
} else {
VSelect.options.methods.selectItem.call(this, item)
VAutocomplete.options.methods.selectItem.call(this, item)
}
},
setSelectedItems () {
Expand Down

0 comments on commit eab8d32

Please sign in to comment.