Fix unexpected modelValue emit if no checkbox value is set (#18552)

* Fix unexpected modelValue emit if no checkbox value is set

* Add changeset
This commit is contained in:
Hannes Küttner
2023-05-11 18:54:42 +02:00
committed by GitHub
parent 1a4d4b8b78
commit 51ec0b1453
2 changed files with 17 additions and 10 deletions

View File

@@ -0,0 +1,5 @@
---
'@directus/app': patch
---
Fixed v-checkbox emit behavior when used with array model-value and the custom-value flag

View File

@@ -12,8 +12,8 @@
<div v-if="$slots.prepend" class="prepend"><slot name="prepend" /></div>
<v-icon class="checkbox" :name="icon" :disabled="disabled" />
<span class="label type-text">
<slot v-if="customValue === false">{{ label }}</slot>
<input v-else v-model="internalValue" class="custom-input" />
<slot v-if="!customValue">{{ label }}</slot>
<input v-else v-model="internalValue" class="custom-input" @click.stop="" />
</span>
<div v-if="$slots.append" class="append"><slot name="append" /></div>
</component>
@@ -92,16 +92,18 @@ function toggleInput(): void {
emit('update:indeterminate', false);
}
if (props.modelValue instanceof Array && props.value) {
const newValue = [...props.modelValue];
if (props.modelValue instanceof Array) {
if (props.value) {
const newValue = [...props.modelValue];
if (props.modelValue.includes(props.value) === false) {
newValue.push(props.value);
} else {
newValue.splice(newValue.indexOf(props.value), 1);
if (!props.modelValue.includes(props.value)) {
newValue.push(props.value);
} else {
newValue.splice(newValue.indexOf(props.value), 1);
}
emit('update:modelValue', newValue);
}
emit('update:modelValue', newValue);
} else {
emit('update:modelValue', !props.modelValue);
}