Skip to content
Open
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
4 changes: 4 additions & 0 deletions src/components/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,10 @@ export default {
onSearchKeyDown(e) {
const preventAndSelect = (e) => {
e.preventDefault()
if (!this.open) {
this.open = true
return
}
return !this.isComposing && this.typeAheadSelect()
}

Expand Down
9 changes: 9 additions & 0 deletions tests/unit/Dropdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ describe('Toggling Dropdown', () => {
expect(Select.vm.search).toEqual('')
})

it('should open dropdown on selectOnKeyCodes keydown', async () => {
const Select = mountDefault()
const input = Select.findComponent({ ref: 'search' })

input.trigger('keydown.enter')

expect(Select.vm.open).toEqual(true)
})

it('should open dropdown on alphabetic input', async () => {
const Select = mountDefault()
const input = Select.findComponent({ ref: 'search' })
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/Keydown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Custom Keydown Handlers', () => {

const spy = jest.spyOn(Select.vm, 'typeAheadSelect')

Select.vm.open = true
Select.findComponent({ ref: 'search' }).trigger('keydown.space')

expect(spy).toHaveBeenCalledTimes(1)
Expand All @@ -33,6 +34,7 @@ describe('Custom Keydown Handlers', () => {

const spy = jest.spyOn(Select.vm, 'typeAheadSelect')

Select.vm.open = true
Select.findComponent({ ref: 'search' }).trigger('keydown.space')
expect(onKeyDown.mock.calls.length).toBe(1)

Expand Down