Skip to content

Commit

Permalink
fix(vautocomplete): change onClick to not reopen menu (vuetifyjs#10158)
Browse files Browse the repository at this point in the history
fix issue where when the append-inner slot is clicked the menu would close with the mouse up event
and then reopen with the click event

fix vuetifyjs#6564

Co-authored-by: Andrew Henry <AMajesticPotatoe@gmail.com>
  • Loading branch information
2 people authored and whoistobias committed Feb 26, 2020
1 parent ecd7add commit 31bf35a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,14 @@ export default VSelect.extend({
? VSelect.options.methods.genSelections.call(this)
: []
},
onClick () {
onClick (e: MouseEvent) {
if (this.isDisabled) return

this.selectedIndex > -1
? (this.selectedIndex = -1)
: this.onFocus()

this.activateMenu()
if (!this.isAppendInner(e.target)) this.activateMenu()
},
onInput (e: Event) {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,38 @@ describe('VAutocomplete.ts', () => {

expect(wrapper.vm.selectedIndex).toBe(-1)
})

it('should close menu when append icon is clicked', async () => {
const wrapper = mountFunction({
propsData: {
items: ['foo', 'bar'],
},
})

const append = wrapper.find('.v-input__append-inner')
const slot = wrapper.find('.v-input__slot')
slot.trigger('click')
expect(wrapper.vm.isMenuActive).toBe(true)
append.trigger('mousedown')
append.trigger('mouseup')
append.trigger('click')
await wrapper.vm.$nextTick()
expect(wrapper.vm.isMenuActive).toBe(false)
})

it('should open menu when append icon is clicked', async () => {
const wrapper = mountFunction({
propsData: {
items: ['foo', 'bar'],
},
})

const append = wrapper.find('.v-input__append-inner')

append.trigger('mousedown')
append.trigger('mouseup')
append.trigger('click')
await wrapper.vm.$nextTick()
expect(wrapper.vm.isMenuActive).toBe(true)
})
})

0 comments on commit 31bf35a

Please sign in to comment.