Skip to content

Commit 8dbacad

Browse files
authored
fix(VColorPicker): Disable swatches (#22472)
fixes #22471
1 parent 3569cd4 commit 8dbacad

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

packages/vuetify/src/components/VColorPicker/VColorPickerSwatches.sass

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
background: $color-picker-checkerboard
2929
cursor: pointer
3030

31+
&--disabled
32+
opacity: var(--v-disabled-opacity)
33+
pointer-events: none
34+
3135
> div
3236
display: flex
3337
align-items: center

packages/vuetify/src/components/VColorPicker/VColorPickerSwatches.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ export const VColorPickerSwatches = defineComponent({
6969
},
7070

7171
setup (props, { emit }) {
72+
function onSwatchClick (hsva: HSV) {
73+
if (props.disabled || !hsva) {
74+
return
75+
}
76+
77+
emit('update:color', hsva)
78+
}
79+
7280
useRender(() => (
7381
<div
7482
class={[
@@ -90,8 +98,13 @@ export const VColorPickerSwatches = defineComponent({
9098

9199
return (
92100
<div
93-
class="v-color-picker-swatches__color"
94-
onClick={ () => hsva && emit('update:color', hsva) }
101+
class={[
102+
'v-color-picker-swatches__color',
103+
{
104+
'v-color-picker-swatches__color--disabled': props.disabled,
105+
},
106+
]}
107+
onClick={ () => onSwatchClick(hsva) }
95108
>
96109
<div style={{ background }}>
97110
{ props.color && deepEqual(props.color, hsva)

0 commit comments

Comments
 (0)