|
20 | 20 | <div v-if="isExpanded" ref="contentContainer" class="comparison-content-container"> |
21 | 21 | <div class="form-row align-items-center mb-2"> |
22 | 22 | <FileMultiSelectDropdown |
23 | | - v-model="internalFileModel" |
| 23 | + :model-value="modelValue" |
24 | 24 | :item_id="item_id" |
25 | 25 | :block_id="block_id" |
26 | 26 | :extensions="extensions" |
27 | 27 | :update-block-on-change="false" |
28 | 28 | :exclude-file-ids="excludeFileIds" |
| 29 | + @update:model-value="$emit('update:modelValue', $event)" |
29 | 30 | /> |
30 | 31 | </div> |
31 | 32 | <div v-if="showApplyButton" class="form-row mt-2 mb-3"> |
32 | | - <button class="btn btn-primary btn-sm" @click="applySelection"> |
| 33 | + <button class="btn btn-primary btn-sm" @click="$emit('apply')"> |
33 | 34 | {{ applyButtonText }} |
34 | 35 | </button> |
35 | 36 | </div> |
@@ -89,35 +90,10 @@ export default { |
89 | 90 | emits: ["update:modelValue", "apply"], |
90 | 91 | data() { |
91 | 92 | return { |
92 | | - internalFileModel: [], |
93 | 93 | isExpanded: false, |
94 | 94 | }; |
95 | 95 | }, |
96 | | - watch: { |
97 | | - modelValue: { |
98 | | - handler(newVal) { |
99 | | - // Avoid triggering the internalFileModel watcher when syncing from parent |
100 | | - if (JSON.stringify(newVal) !== JSON.stringify(this.internalFileModel)) { |
101 | | - this.internalFileModel = newVal.slice(); |
102 | | - } |
103 | | - }, |
104 | | - deep: true, |
105 | | - }, |
106 | | - internalFileModel: { |
107 | | - handler(newVal, oldVal) { |
108 | | - // Emit changes immediately when showApplyButton is false |
109 | | - // Only emit if the value actually changed |
110 | | - if (!this.showApplyButton && JSON.stringify(newVal) !== JSON.stringify(oldVal)) { |
111 | | - this.$emit("update:modelValue", newVal.slice()); |
112 | | - } |
113 | | - }, |
114 | | - deep: true, |
115 | | - }, |
116 | | - }, |
117 | 96 | mounted() { |
118 | | - // Initialize internal model from prop |
119 | | - this.internalFileModel = this.modelValue.slice(); |
120 | | -
|
121 | 97 | // Set initial expanded state |
122 | 98 | this.isExpanded = this.initiallyExpanded; |
123 | 99 | }, |
@@ -155,11 +131,6 @@ export default { |
155 | 131 | el.offsetHeight; |
156 | 132 | el.style.height = "0"; |
157 | 133 | }, |
158 | | -
|
159 | | - applySelection() { |
160 | | - this.$emit("update:modelValue", this.internalFileModel.slice()); |
161 | | - this.$emit("apply", this.internalFileModel.slice()); |
162 | | - }, |
163 | 134 | }, |
164 | 135 | }; |
165 | 136 | </script> |
|
0 commit comments