From c4b582736652c365ce69dbf52cff7a8b95594387 Mon Sep 17 00:00:00 2001 From: Neha Gokhale Date: Fri, 3 Jan 2025 12:21:00 -0800 Subject: [PATCH] =?UTF-8?q?=C2=A0#2287=20Fixed=20Common=20properties=20cal?= =?UTF-8?q?lbacks=20don't=20update=20on=20re-render=20(#2288)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties-main/properties-main.jsx | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/canvas_modules/common-canvas/src/common-properties/properties-main/properties-main.jsx b/canvas_modules/common-canvas/src/common-properties/properties-main/properties-main.jsx index 26b8d8ad4..657db29f7 100644 --- a/canvas_modules/common-canvas/src/common-properties/properties-main/properties-main.jsx +++ b/canvas_modules/common-canvas/src/common-properties/properties-main/properties-main.jsx @@ -59,17 +59,7 @@ class PropertiesMain extends React.Component { this.propertiesController.setLight(props.light); this.propertiesController.setAppData(props.propertiesInfo.appData); this.propertiesController.setExpressionInfo(props.propertiesInfo.expressionInfo); - this.propertiesController.setHandlers({ - controllerHandler: props.callbacks.controllerHandler, - propertyListener: props.callbacks.propertyListener, - actionHandler: props.callbacks.actionHandler, - buttonHandler: props.callbacks.buttonHandler, - buttonIconHandler: props.callbacks.buttonIconHandler, - validationHandler: props.callbacks.validationHandler, - titleChangeHandler: props.callbacks.titleChangeHandler, - tooltipLinkHandler: props.callbacks.tooltipLinkHandler, - propertyIconHandler: props.callbacks.propertyIconHandler, - }); + this.setCallbacks(); this.setForm(props.propertiesInfo, false); this.previousErrorMessages = {}; // this has to be after setForm because setForm clears all error messages. @@ -143,6 +133,12 @@ class PropertiesMain extends React.Component { } } + componentDidUpdate(prevProps) { + if (!isEqual(prevProps.callbacks, this.props.callbacks)) { + this.setCallbacks(); + } + } + onBlur(e) { // apply properties when focus leave common properties. // subdialogs and summary panel causes focus to leave but shouldn't apply settings @@ -153,6 +149,20 @@ class PropertiesMain extends React.Component { } } + setCallbacks() { + this.propertiesController.setHandlers({ + controllerHandler: this.props.callbacks.controllerHandler, + propertyListener: this.props.callbacks.propertyListener, + actionHandler: this.props.callbacks.actionHandler, + buttonHandler: this.props.callbacks.buttonHandler, + buttonIconHandler: this.props.callbacks.buttonIconHandler, + validationHandler: this.props.callbacks.validationHandler, + titleChangeHandler: this.props.callbacks.titleChangeHandler, + tooltipLinkHandler: this.props.callbacks.tooltipLinkHandler, + propertyIconHandler: this.props.callbacks.propertyIconHandler, + }); + } + setForm(propertiesInfo, sameParameterDefRendered) { let formData = null;