mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
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:
5
.changeset/smart-countries-admire.md
Normal file
5
.changeset/smart-countries-admire.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@directus/app': patch
|
||||
---
|
||||
|
||||
Fixed v-checkbox emit behavior when used with array model-value and the custom-value flag
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user