Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VListItem): dont trigger kb events for disabled item #15339

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/vuetify/src/components/VList/VListItem.ts
Expand Up @@ -168,10 +168,12 @@ export default baseMixins.extend<options>().extend({
data[this.to ? 'nativeOn' : 'on'] = {
...data[this.to ? 'nativeOn' : 'on'],
keydown: (e: KeyboardEvent) => {
/* istanbul ignore else */
if (e.keyCode === keyCodes.enter) this.click(e)
if (!this.disabled) {
/* istanbul ignore else */
if (e.keyCode === keyCodes.enter) this.click(e)

this.$emit('keydown', e)
this.$emit('keydown', e)
}
},
}

Expand Down
12 changes: 12 additions & 0 deletions packages/vuetify/src/components/VList/__tests__/VListItem.spec.ts
Expand Up @@ -234,4 +234,16 @@ describe('VListItem.ts', () => {
wrapper2.vm.toggle()
expect(wrapper2.vm.isActive).toBeTruthy()
})

it('should not react to keydown.enter when disabled', () => {
const click = jest.fn()
const wrapper = mountFunction({
methods: { click },
propsData: { disabled: true },
})

wrapper.trigger('keydown.enter')

expect(click).not.toHaveBeenCalled()
})
})