From ed34cb0d5f9819bf202090c316cb2083e2f4d9f6 Mon Sep 17 00:00:00 2001 From: Jerinjk14 Date: Wed, 4 Dec 2024 00:21:44 +0530 Subject: [PATCH] =?UTF-8?q?#2248=20After=20table=20row=20is=20deleted,=20p?= =?UTF-8?q?ropertyListener=20callback=20has=20same=20=E2=80=A6=20(#2249)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties-controller.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/canvas_modules/common-canvas/src/common-properties/properties-controller.js b/canvas_modules/common-canvas/src/common-properties/properties-controller.js index 48e8e35f01..e4623fe3c0 100644 --- a/canvas_modules/common-canvas/src/common-properties/properties-controller.js +++ b/canvas_modules/common-canvas/src/common-properties/properties-controller.js @@ -542,8 +542,8 @@ export default class PropertiesController { } else if (subControl.valueDef.propType === "enum") { val = subControl.values[0]; } else if (subControl.valueDef.propType === "integer" || - subControl.valueDef.propType === "long" || - subControl.valueDef.propType === "double") { + subControl.valueDef.propType === "long" || + subControl.valueDef.propType === "double") { val = 0; } else if (subControl.valueDef.propType === "structure") { val = {}; @@ -1115,6 +1115,15 @@ export default class PropertiesController { getPropertyValue(inPropertyId, options, defaultValue) { const propertyId = this.convertPropertyId(inPropertyId); const propertyValue = this.propertiesStore.getPropertyValue(propertyId); + let parsedValue; + if (Array.isArray(propertyValue)) { + parsedValue = propertyValue.map((itm) => itm); + } else if (propertyValue && typeof propertyValue === "object") { + // Shallow copy for objects + parsedValue = { ...propertyValue }; + } else { + parsedValue = propertyValue; + } let filteredValue = defaultValue; // don't return hidden/disabled values @@ -1166,7 +1175,7 @@ export default class PropertiesController { if (options && options.applyProperties === true) { return this._convertObjectStructure(propertyId, propertyValue); } - return propertyValue; + return parsedValue; } removePropertyValue(inPropertyId) { @@ -1279,7 +1288,7 @@ export default class PropertiesController { const control = this.getControl({ name: parameterRef }); if (PropertyUtils.isSubControlStructureObjectType(control)) { conditionalDefaultValues[parameterRef] = - PropertyUtils.convertObjectStructureToArray(control.valueDef.isList, control.subControls, conditionalDefaultValues[parameterRef]); + PropertyUtils.convertObjectStructureToArray(control.valueDef.isList, control.subControls, conditionalDefaultValues[parameterRef]); } this.propertiesStore.updatePropertyValue({ name: parameterRef }, conditionalDefaultValues[parameterRef]); } @@ -2045,7 +2054,7 @@ export default class PropertiesController { }); const isDifference = consecutiveAry.every((value) => value === 1); if (isDifference && ((staticRows.includes(0) && !staticRows.includes(controlValue.length - 1)) || - (!staticRows.includes(0) && staticRows.includes(controlValue.length - 1)))) { + (!staticRows.includes(0) && staticRows.includes(controlValue.length - 1)))) { isValid = true; } else { isValid = false;