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(VItem): support disabled effect #14941

Merged
merged 4 commits into from Jul 5, 2023
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
4 changes: 4 additions & 0 deletions packages/vuetify/src/components/VItemGroup/VItem.sass
@@ -0,0 +1,4 @@
.v-item--disabled
&,
& *
pointer-events: none
13 changes: 12 additions & 1 deletion packages/vuetify/src/components/VItemGroup/VItem.ts
@@ -1,3 +1,6 @@
// Styles
import './VItem.sass'

// Mixins
import { factory as GroupableFactory } from '../../mixins/groupable'

Expand All @@ -16,6 +19,7 @@ export const BaseItem = Vue.extend({
value: {
required: false,
},
disabled: Boolean,
},

data: () => ({
Expand Down Expand Up @@ -56,9 +60,16 @@ export const BaseItem = Vue.extend({
}

element.data = this._b(element.data || {}, element.tag!, {
class: { [this.activeClass]: this.isActive },
class: {
[this.activeClass]: this.isActive,
'v-item--disabled': this.disabled,
},
})

if (this.disabled) {
element.data.attrs = { ...element.data.attrs, tabindex: -1 }
}

return element
},
})
Expand Down
11 changes: 9 additions & 2 deletions packages/vuetify/src/mixins/groupable/index.ts
Expand Up @@ -11,7 +11,7 @@ export type Groupable<T extends string, C extends VueConstructor | null = null>
isActive: boolean
disabled: boolean
groupClasses: object
toggle (): void
toggle (e?: Event): void
}>

export function factory<T extends string, C extends VueConstructor | null = null> (
Expand Down Expand Up @@ -59,7 +59,14 @@ export function factory<T extends string, C extends VueConstructor | null = null
},

methods: {
toggle () {
toggle (e?: Event) {
if (this.disabled && e) {
// Prevent keyboard actions
// from children elements
// within disabled tabs
e.preventDefault()
return
}
this.$emit('change')
},
},
Expand Down