From 827b8d1914c5d1230766bdfa65a162e13bffef9a Mon Sep 17 00:00:00 2001 From: Mert Sincan Date: Tue, 22 Oct 2024 10:40:03 +0100 Subject: [PATCH] Fixed Checkbox state in MultiSelect --- .../baseeditableholder/BaseEditableHolder.vue | 18 +++++++++++++----- .../primevue/src/multiselect/MultiSelect.vue | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/core/src/baseeditableholder/BaseEditableHolder.vue b/packages/core/src/baseeditableholder/BaseEditableHolder.vue index 2eea35a2d..3a27d9c4e 100644 --- a/packages/core/src/baseeditableholder/BaseEditableHolder.vue +++ b/packages/core/src/baseeditableholder/BaseEditableHolder.vue @@ -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; - this.$emit('value-change', value); - - // controlled - this.$emit('update:modelValue', 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; diff --git a/packages/primevue/src/multiselect/MultiSelect.vue b/packages/primevue/src/multiselect/MultiSelect.vue index 2519f4efe..f0e9590d9 100755 --- a/packages/primevue/src/multiselect/MultiSelect.vue +++ b/packages/primevue/src/multiselect/MultiSelect.vue @@ -156,7 +156,7 @@ :data-p-focused="focusedOptionIndex === getOptionIndex(i, getItemOptions)" :data-p-disabled="isOptionDisabled(option)" > - +