Skip to content

Commit

Permalink
fix(VSelect): ignore keypress when readonly (#8194)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukano authored and johnleider committed Aug 12, 2019
1 parent 3beea7c commit 0f92fc9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/vuetify/src/components/VSelect/VSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,10 @@ export default baseMixins.extend<options>().extend({
}
},
onKeyPress (e: KeyboardEvent) {
if (this.multiple) return
if (
this.multiple ||
this.readonly
) return

const KEYBOARD_LOOKUP_THRESHOLD = 1000 // milliseconds
const now = performance.now()
Expand Down
23 changes: 23 additions & 0 deletions packages/vuetify/src/components/VSelect/__tests__/VSelect4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,27 @@ describe('VSelect.ts', () => {
expect(wrapper.vm.internalValue).toBe('Foo')
expect(wrapper.vm.$refs.menu.listIndex).toBe(-1)
})

it('should not change value when typing on readonly field', async () => {
const wrapper = mountFunction({
propsData: {
items: ['Foo', 'Bar', 'Fizz', 'Buzz'],
readonly: true,
value: 'Foo',
},
})

const input = wrapper.find('input')
input.trigger('click')

await wrapper.vm.$nextTick()

expect(wrapper.vm.internalValue).toBe('Foo')

input.trigger('keypress', { key: 'b' })

await wrapper.vm.$nextTick()

expect(wrapper.vm.internalValue).toBe('Foo')
})
})

0 comments on commit 0f92fc9

Please sign in to comment.