Skip to content

Commit 637b26f

Browse files
be-smithml-evs
authored andcommitted
Removed some watchers and complexity that was redundant
1 parent df95bcb commit 637b26f

File tree

1 file changed

+3
-32
lines changed

1 file changed

+3
-32
lines changed

webapp/src/components/CollapsibleComparisonFileSelect.vue

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
<div v-if="isExpanded" ref="contentContainer" class="comparison-content-container">
2121
<div class="form-row align-items-center mb-2">
2222
<FileMultiSelectDropdown
23-
v-model="internalFileModel"
23+
:model-value="modelValue"
2424
:item_id="item_id"
2525
:block_id="block_id"
2626
:extensions="extensions"
2727
:update-block-on-change="false"
2828
:exclude-file-ids="excludeFileIds"
29+
@update:model-value="$emit('update:modelValue', $event)"
2930
/>
3031
</div>
3132
<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')">
3334
{{ applyButtonText }}
3435
</button>
3536
</div>
@@ -89,35 +90,10 @@ export default {
8990
emits: ["update:modelValue", "apply"],
9091
data() {
9192
return {
92-
internalFileModel: [],
9393
isExpanded: false,
9494
};
9595
},
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-
},
11796
mounted() {
118-
// Initialize internal model from prop
119-
this.internalFileModel = this.modelValue.slice();
120-
12197
// Set initial expanded state
12298
this.isExpanded = this.initiallyExpanded;
12399
},
@@ -155,11 +131,6 @@ export default {
155131
el.offsetHeight;
156132
el.style.height = "0";
157133
},
158-
159-
applySelection() {
160-
this.$emit("update:modelValue", this.internalFileModel.slice());
161-
this.$emit("apply", this.internalFileModel.slice());
162-
},
163134
},
164135
};
165136
</script>

0 commit comments

Comments
 (0)