From 043cf14fbad5e04e5aca547268e0b7bfa7b847b8 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Mon, 25 Nov 2024 19:17:23 -0300 Subject: [PATCH] fix: improve node internal updates in setNodeClass function (#4836) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ (use-handle-new-value.tsx): change the callback function to be asynchronous to introduce a delay of 500ms before updating node internals * 🐛 (use-handle-new-value.tsx): fix setNode function call to include additional parameters for immediate update and callback function to update node internals after setting the node class. * 🔧 (use-handle-new-value.tsx): Remove unnecessary line break to improve code readability and consistency * 🔧 (.github/workflows/typescript_test.yml): update matrix output to ensure proper JSON formatting using jq command --- .github/workflows/typescript_test.yml | 5 ++-- .../hooks/use-handle-new-value.tsx | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/typescript_test.yml b/.github/workflows/typescript_test.yml index daa9016f4..f31320d86 100644 --- a/.github/workflows/typescript_test.yml +++ b/.github/workflows/typescript_test.yml @@ -12,7 +12,7 @@ on: description: "Test suites to run (JSON array)" required: false type: string - default: '[]' + default: "[]" release: description: "Whether this is a release build" required: false @@ -153,7 +153,8 @@ jobs: echo "Final test suites to run: $SUITES" echo "Test grep pattern: $TEST_GREP" - echo "matrix=$SUITES" >> $GITHUB_OUTPUT + # Ensure proper JSON formatting for matrix output + echo "matrix=$(echo $SUITES | jq -c .)" >> $GITHUB_OUTPUT echo "test_grep=$TEST_GREP" >> $GITHUB_OUTPUT setup-and-test: diff --git a/src/frontend/src/CustomNodes/hooks/use-handle-new-value.tsx b/src/frontend/src/CustomNodes/hooks/use-handle-new-value.tsx index de34135e7..9ecb1dc53 100644 --- a/src/frontend/src/CustomNodes/hooks/use-handle-new-value.tsx +++ b/src/frontend/src/CustomNodes/hooks/use-handle-new-value.tsx @@ -37,7 +37,6 @@ const useHandleOnNewValue = ({ const updateNodeInternals = useUpdateNodeInternals(); const setErrorData = useAlertStore((state) => state.setErrorData); - const postTemplateValue = usePostTemplateValue({ parameterId: name, nodeId: nodeId, @@ -72,14 +71,21 @@ const useHandleOnNewValue = ({ const setNodeClass = (newNodeClass: APIClassType) => { options?.setNodeClass && options.setNodeClass(newNodeClass); - setNode(nodeId, (oldNode) => { - const newData = cloneDeep(oldNode.data); - newData.node = newNodeClass; - return { - ...oldNode, - data: newData, - }; - }); + setNode( + nodeId, + (oldNode) => { + const newData = cloneDeep(oldNode.data); + newData.node = newNodeClass; + return { + ...oldNode, + data: newData, + }; + }, + true, + () => { + updateNodeInternals(nodeId); + }, + ); }; if (shouldUpdate && changes.value !== undefined) {