Skip to content

Commit 7822179

Browse files
authored
fix(VColorInput): ensure cancel action closes menu (#21664)
fixes #21655
1 parent 25d2b3f commit 7822179

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

packages/vuetify/src/labs/VColorInput/VColorInput.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ export const VColorInput = genericComponent<VColorInputSlots>()({
8686
menu.value = false
8787
}
8888

89+
function onCancel () {
90+
menu.value = false
91+
}
92+
8993
useRender(() => {
9094
const confirmEditProps = VConfirmEdit.filterProps(props)
9195
const colorPickerProps = VColorPicker.filterProps(omit(props, ['active', 'color']))
@@ -139,17 +143,23 @@ export const VColorInput = genericComponent<VColorInputSlots>()({
139143
{ ...confirmEditProps }
140144
v-model={ model.value }
141145
onSave={ onSave }
146+
onCancel={ onCancel }
142147
>
143148
{{
144149
default: ({ actions, model: proxyModel, save, cancel, isPristine }) => {
150+
function onUpdateModel (value: string) {
151+
if (!props.hideActions) {
152+
proxyModel.value = value
153+
} else {
154+
model.value = value
155+
}
156+
}
157+
145158
return (
146159
<VColorPicker
147160
{ ...colorPickerProps }
148-
modelValue={ proxyModel.value }
149-
onUpdate:modelValue={ val => {
150-
proxyModel.value = val
151-
model.value = val
152-
}}
161+
modelValue={ props.hideActions ? model.value : proxyModel.value }
162+
onUpdate:modelValue={ value => onUpdateModel(value) }
153163
onMousedown={ (e: MouseEvent) => e.preventDefault() }
154164
>
155165
{{

0 commit comments

Comments
 (0)