You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by ti...@apache.org on 2025/03/07 21:49:09 UTC

(incubator-kie-tools) branch main updated: kie-issues#1864: Renaming a Decision node using the Boxed Expression Editor makes DMN model invalid by breaking Decision Table (#2972)

This is an automated email from the ASF dual-hosted git repository.

tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new b51faa88b3e kie-issues#1864: Renaming a Decision node using the Boxed Expression Editor makes DMN model invalid by breaking Decision Table (#2972)
b51faa88b3e is described below

commit b51faa88b3e529cacfd5bb1aa54ddddc05c9c845
Author: Daniel José dos Santos <da...@users.noreply.github.com>
AuthorDate: Fri Mar 7 18:49:06 2025 -0300

    kie-issues#1864: Renaming a Decision node using the Boxed Expression Editor makes DMN model invalid by breaking Decision Table (#2972)
---
 .../src/contextMenu/PopoverMenu/PopoverMenu.tsx              | 11 ++++++++---
 .../src/expressionVariable/ExpressionVariableMenu.tsx        | 12 +++++-------
 packages/dmn-feel-antlr4-parser/src/parser/Expression.ts     |  4 +++-
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/packages/boxed-expression-component/src/contextMenu/PopoverMenu/PopoverMenu.tsx b/packages/boxed-expression-component/src/contextMenu/PopoverMenu/PopoverMenu.tsx
index c6688736850..b0e813aa98a 100644
--- a/packages/boxed-expression-component/src/contextMenu/PopoverMenu/PopoverMenu.tsx
+++ b/packages/boxed-expression-component/src/contextMenu/PopoverMenu/PopoverMenu.tsx
@@ -119,10 +119,15 @@ export const PopoverMenu = React.forwardRef(
 
     const onHideCallback: PopoverProps["onHide"] = useCallback(
       (tip): void => {
-        onHide();
-        setCurrentlyOpenContextMenu(undefined);
+        // This validation is to prevent this code of being called twice, because if the user clicks outside the
+        // Boxed Expression component the onHide() is called again by the Popover which is listen to clicks
+        // on the document to close all opened popups.
+        if (currentlyOpenContextMenu) {
+          onHide();
+          setCurrentlyOpenContextMenu(undefined);
+        }
       },
-      [onHide, setCurrentlyOpenContextMenu]
+      [currentlyOpenContextMenu, onHide, setCurrentlyOpenContextMenu]
     );
 
     useImperativeHandle(
diff --git a/packages/boxed-expression-component/src/expressionVariable/ExpressionVariableMenu.tsx b/packages/boxed-expression-component/src/expressionVariable/ExpressionVariableMenu.tsx
index 0664da443cf..0a726e2f176 100644
--- a/packages/boxed-expression-component/src/expressionVariable/ExpressionVariableMenu.tsx
+++ b/packages/boxed-expression-component/src/expressionVariable/ExpressionVariableMenu.tsx
@@ -153,12 +153,7 @@ export function ExpressionVariableMenu({
     }
     saveExpression();
     popoverMenuRef?.current?.setIsVisible(false);
-    // We reset the expression name to its default because the name change could be canceled outside.
-    // If we don't reset it, we will keep it an outdated name.
-    // If the change is confirmed, then the selectExpressionName will be updated to the new one in the next
-    // render of this component.
-    setExpressionName(selectedExpressionName);
-  }, [saveExpression, selectedExpressionName]);
+  }, [saveExpression]);
 
   const onCancel = useCallback(() => {
     cancelEdit.current = true;
@@ -167,8 +162,11 @@ export function ExpressionVariableMenu({
   }, [resetFormData]);
 
   const onShown = useCallback(() => {
+    // We need to refresh the expression name from the selectedExpressionName,
+    // otherwise it will show the older name set in expressionName.
+    setExpressionName(selectedExpressionName);
     expressionNameRef.current?.focus();
-  }, []);
+  }, [selectedExpressionName]);
 
   const onKeyDown = useCallback(
     (e: React.KeyboardEvent) => {
diff --git a/packages/dmn-feel-antlr4-parser/src/parser/Expression.ts b/packages/dmn-feel-antlr4-parser/src/parser/Expression.ts
index edce40687b5..de2369e30d1 100644
--- a/packages/dmn-feel-antlr4-parser/src/parser/Expression.ts
+++ b/packages/dmn-feel-antlr4-parser/src/parser/Expression.ts
@@ -35,7 +35,9 @@ export class Expression {
   }
 
   public applyChangesToExpressionSource() {
-    this.source.text = { __$$text: this._fullExpression };
+    if (this.source.text) {
+      this.source.text = { __$$text: this._fullExpression };
+    }
   }
 
   public renameIdentifier(identifier: Identifier, newName: String) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org