From 239577e9cfde6680e62aac6c96cd0d804dec4817 Mon Sep 17 00:00:00 2001 From: chfhtw Date: Mon, 20 Apr 2026 15:17:07 +0200 Subject: [PATCH] safeguard watchers; move indexedItems watcher code into a method and reuse it in cols watcher --- public/js/components/Drop/Grid.js | 35 ++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/public/js/components/Drop/Grid.js b/public/js/components/Drop/Grid.js index 70d7f2c9a..0fb94289a 100644 --- a/public/js/components/Drop/Grid.js +++ b/public/js/components/Drop/Grid.js @@ -218,28 +218,27 @@ export default { }, watch: { active(active) { - if (!active) + if (!active && this.mode != MODE_IDLE) this.dragCancel(); }, - cols() { - this.dragCancel(); + cols(value, oldValue) { + if (value == oldValue) + return; + + this.reinitGrid(); }, rows: { - handler(value) { + handler(value, oldValue) { + if (value == oldValue) + return; + this.$emit('gridHeight', value); }, immediate: true }, indexedItems: { handler(value) { - if (this.mode != MODE_IDLE) - this.dragCancel(); - - const updated = this.createNewGrid(value); - - this.correctedPositionUpdates = updated; - if (updated.length) - this.$emit('rearrangeItems', updated.filter(v => v)); + this.reinitGrid(); }, immediate: true, deep: true @@ -247,6 +246,18 @@ export default { }, methods: { // helpers + reinitGrid() { + if (this.mode != MODE_IDLE) + this.dragCancel(); + + const updated = this.createNewGrid(this.indexedItems); + + this.correctedPositionUpdates = updated; + if (updated.length) + updated = updated.filter(v => v); + if (updated.length) + this.$emit('rearrangeItems', updated); + }, convertGridResultToUpdate(input, output, baseArray) { if (!input) return;