From da9c2eba5ab7014ab3f4a8bdfba7ec1d60966ed2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 22 Nov 2025 16:54:00 +0000 Subject: [PATCH] CRITICAL FIX: Region selector to array index mapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: When user selected "Region 1" and edited box position, it was actually moving Region 2's box instead. Root Cause: transformFunc was using region selector value directly as array index without converting from 1-based UI to 0-based array indexing. - Region selector displays: "Region 1", "Region 2", etc. (1-based for users) - Behind the scenes: array[0], array[1], etc. (0-based for storage) Fix: In transformFunc, subtract 1 from region selector value before using as array index: regionSelectorValue = 1 → arrayIndex = 0 → updates array[0] (Region 1) regionSelectorValue = 2 → arrayIndex = 1 → updates array[1] (Region 2) Now editing "Region 1" box correctly updates the first region in the array. --- js/utils.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/utils.js b/js/utils.js index a7577b5..22a6a7f 100644 --- a/js/utils.js +++ b/js/utils.js @@ -41,8 +41,11 @@ export function recursiveLinkUpstream(node, type, depth, index=null) { export function transformFunc(widget, value, node, index) { const s = widget.options.step / 10; widget.value = Math.round(value / s) * s; - node.properties["values"][node.widgets[node.index].value][index] = widget.value - if (node.widgets_values) { + // Convert 1-based region selector (Region 1, Region 2...) to 0-based array index + const regionSelectorValue = node.widgets[node.index].value; + const arrayIndex = regionSelectorValue - 1; // Region 1 → index 0, Region 2 → index 1, etc. + node.properties["values"][arrayIndex][index] = widget.value + if (node.widgets_values) { node.widgets_values[2] = node.properties["values"].join() } }