Skip to content

Commit 817df79

Browse files
lampdevlampdev
andauthored
fix(VList): don't trigger keyboard events on disabled items (#15339)
resolves #15322 Co-authored-by: lampdev <orders@lampdev.com>
1 parent ff519c6 commit 817df79

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

packages/vuetify/src/components/VList/VListItem.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,12 @@ export default baseMixins.extend<options>().extend({
168168
data[this.to ? 'nativeOn' : 'on'] = {
169169
...data[this.to ? 'nativeOn' : 'on'],
170170
keydown: (e: KeyboardEvent) => {
171-
/* istanbul ignore else */
172-
if (e.keyCode === keyCodes.enter) this.click(e)
171+
if (!this.disabled) {
172+
/* istanbul ignore else */
173+
if (e.keyCode === keyCodes.enter) this.click(e)
173174

174-
this.$emit('keydown', e)
175+
this.$emit('keydown', e)
176+
}
175177
},
176178
}
177179

packages/vuetify/src/components/VList/__tests__/VListItem.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,16 @@ describe('VListItem.ts', () => {
234234
wrapper2.vm.toggle()
235235
expect(wrapper2.vm.isActive).toBeTruthy()
236236
})
237+
238+
it('should not react to keydown.enter when disabled', () => {
239+
const click = jest.fn()
240+
const wrapper = mountFunction({
241+
methods: { click },
242+
propsData: { disabled: true },
243+
})
244+
245+
wrapper.trigger('keydown.enter')
246+
247+
expect(click).not.toHaveBeenCalled()
248+
})
237249
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy