CRITICAL FIX: Region selector to array index mapping
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.
This commit is contained in:
+5
-2
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user