Fixed Checkbox state in MultiSelect

pull/6632/head
Mert Sincan 2024-10-22 10:40:03 +01:00
parent 06f9b5f630
commit 827b8d1914
2 changed files with 14 additions and 6 deletions

View File

@ -49,6 +49,9 @@ export default {
modelValue(newValue) {
this.d_value = newValue;
},
defaultValue(newValue) {
this.d_value = newValue;
},
formControl: {
immediate: true,
handler(newValue) {
@ -66,11 +69,13 @@ export default {
methods: {
updateValue(value, event) {
// uncontrolled
this.d_value = value;
if (this.uncontolled) {
this.$emit('value-change', value);
} else {
// controlled
this.d_value = value;
this.$emit('update:modelValue', value);
}
this.formField.onChange?.({ originalEvent: event, value });
}
@ -85,6 +90,9 @@ export default {
$formName() {
return this.formControl?.name || this.name;
},
uncontolled() {
return this.defaultValue !== undefined && this.modelValue === undefined;
},
// @deprecated use $filled instead
filled() {
return this.$filled;

View File

@ -156,7 +156,7 @@
:data-p-focused="focusedOptionIndex === getOptionIndex(i, getItemOptions)"
:data-p-disabled="isOptionDisabled(option)"
>
<Checkbox :modelValue="isSelected(option)" :binary="true" :tabindex="-1" :variant="variant" :unstyled="unstyled" :pt="getCheckboxPTOptions(option, getItemOptions, i, 'pcOptionCheckbox')">
<Checkbox :defaultValue="isSelected(option)" :binary="true" :tabindex="-1" :variant="variant" :unstyled="unstyled" :pt="getCheckboxPTOptions(option, getItemOptions, i, 'pcOptionCheckbox')">
<template #icon="slotProps">
<component v-if="$slots.optioncheckboxicon || $slots.itemcheckboxicon" :is="$slots.optioncheckboxicon || $slots.itemcheckboxicon" :checked="slotProps.checked" :class="slotProps.class" />
<component