From e691a20ea18c90668e2875b946824b2de32141d0 Mon Sep 17 00:00:00 2001 From: TianYun Date: Thu, 18 Jun 2026 18:03:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E5=89=B2=E8=8A=82=E7=82=B9=E6=9C=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/SplitGridNode.test.tsx | 18 +++++++++++++++--- src/components/nodes/SplitGridNode.tsx | 8 +++++--- src/store/utils/__tests__/nodeDefaults.test.ts | 1 + src/store/utils/nodeDefaults.ts | 1 + src/types/nodes.ts | 1 + 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/components/__tests__/SplitGridNode.test.tsx b/src/components/__tests__/SplitGridNode.test.tsx index 0d4d3606..a6dacdbe 100644 --- a/src/components/__tests__/SplitGridNode.test.tsx +++ b/src/components/__tests__/SplitGridNode.test.tsx @@ -209,15 +209,27 @@ describe("SplitGridNode", () => { expect(screen.queryByTestId("split-grid-settings-modal")).not.toBeInTheDocument(); }); - it("should auto-open settings when not configured and no child nodes", () => { + it("should auto-open settings for a freshly created split grid node", () => { render( - + ); - // Modal should be open automatically expect(screen.getByTestId("split-grid-settings-modal")).toBeInTheDocument(); + expect(mockUpdateNodeData).toHaveBeenCalledWith("split-grid-node-1", { + shouldOpenSettingsOnCreate: false, + }); + }); + + it("should not auto-open settings for loaded unconfigured split grid nodes", () => { + render( + + + + ); + + expect(screen.queryByTestId("split-grid-settings-modal")).not.toBeInTheDocument(); }); it("should not auto-open settings when already configured", () => { diff --git a/src/components/nodes/SplitGridNode.tsx b/src/components/nodes/SplitGridNode.tsx index 82bdba27..9b62c182 100644 --- a/src/components/nodes/SplitGridNode.tsx +++ b/src/components/nodes/SplitGridNode.tsx @@ -43,12 +43,14 @@ export function SplitGridNode({ id, data, selected }: NodeProps { - if (!nodeData.isConfigured && (!nodeData.childNodeIds || nodeData.childNodeIds.length === 0)) { + if (nodeData.shouldOpenSettingsOnCreate) { setShowSettings(true); + updateNodeData(id, { shouldOpenSettingsOnCreate: false }); } - }, [nodeData.isConfigured, nodeData.childNodeIds]); + }, [id, nodeData.shouldOpenSettingsOnCreate, updateNodeData]); const handleOpenSettings = useCallback(() => { setShowSettings(true); diff --git a/src/store/utils/__tests__/nodeDefaults.test.ts b/src/store/utils/__tests__/nodeDefaults.test.ts index 3daf040f..e7d856fc 100644 --- a/src/store/utils/__tests__/nodeDefaults.test.ts +++ b/src/store/utils/__tests__/nodeDefaults.test.ts @@ -193,6 +193,7 @@ describe("nodeDefaults utilities", () => { expect(data).toHaveProperty("gridRows", 2); expect(data).toHaveProperty("gridCols", 3); expect(data).toHaveProperty("isConfigured", false); + expect(data).toHaveProperty("shouldOpenSettingsOnCreate", true); expect(data).toHaveProperty("status", "idle"); expect(data).toHaveProperty("error", null); }); diff --git a/src/store/utils/nodeDefaults.ts b/src/store/utils/nodeDefaults.ts index 9190c94e..d9cb11d5 100644 --- a/src/store/utils/nodeDefaults.ts +++ b/src/store/utils/nodeDefaults.ts @@ -364,6 +364,7 @@ export const createDefaultNodeData = (type: NodeType): WorkflowNodeData => { gridRows: 2, gridCols: 3, isConfigured: false, + shouldOpenSettingsOnCreate: true, status: "idle", error: null, } as SplitGridNodeData; diff --git a/src/types/nodes.ts b/src/types/nodes.ts index 4a11b97f..d7f37132 100644 --- a/src/types/nodes.ts +++ b/src/types/nodes.ts @@ -542,6 +542,7 @@ export interface SplitGridNodeData extends BaseNodeData { gridRows: number; gridCols: number; isConfigured: boolean; + shouldOpenSettingsOnCreate?: boolean; status: NodeStatus; error: string | null; }