Skip to content

Commit 415322d

Browse files
authored
fix(VItem): support disabled effect (#14941)
fixes #14923
1 parent 922e05a commit 415322d

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.v-item--disabled
2+
&,
3+
& *
4+
pointer-events: none

packages/vuetify/src/components/VItemGroup/VItem.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Styles
2+
import './VItem.sass'
3+
14
// Mixins
25
import { factory as GroupableFactory } from '../../mixins/groupable'
36

@@ -16,6 +19,7 @@ export const BaseItem = Vue.extend({
1619
value: {
1720
required: false,
1821
},
22+
disabled: Boolean,
1923
},
2024

2125
data: () => ({
@@ -56,9 +60,16 @@ export const BaseItem = Vue.extend({
5660
}
5761

5862
element.data = this._b(element.data || {}, element.tag!, {
59-
class: { [this.activeClass]: this.isActive },
63+
class: {
64+
[this.activeClass]: this.isActive,
65+
'v-item--disabled': this.disabled,
66+
},
6067
})
6168

69+
if (this.disabled) {
70+
element.data.attrs = { ...element.data.attrs, tabindex: -1 }
71+
}
72+
6273
return element
6374
},
6475
})

packages/vuetify/src/mixins/groupable/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type Groupable<T extends string, C extends VueConstructor | null = null>
1111
isActive: boolean
1212
disabled: boolean
1313
groupClasses: object
14-
toggle (): void
14+
toggle (e?: Event): void
1515
}>
1616

1717
export function factory<T extends string, C extends VueConstructor | null = null> (
@@ -59,7 +59,14 @@ export function factory<T extends string, C extends VueConstructor | null = null
5959
},
6060

6161
methods: {
62-
toggle () {
62+
toggle (e?: Event) {
63+
if (this.disabled && e) {
64+
// Prevent keyboard actions
65+
// from children elements
66+
// within disabled tabs
67+
e.preventDefault()
68+
return
69+
}
6370
this.$emit('change')
6471
},
6572
},

0 commit comments

Comments
 (0)