From d72079a5801e1edfadabcab52e3f85bf2d63ba93 Mon Sep 17 00:00:00 2001 From: mlogclub Date: Tue, 30 Jun 2026 11:39:01 +0800 Subject: [PATCH] feat: implement isBranchRowActionTarget function and add tests for branch row interaction --- .../workflow-condition-node-content.tsx | 4 ++++ .../_components/workflow-utils.test.mjs | 17 +++++++++++++++++ .../ai-workflows/_components/workflow-utils.ts | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/web/app/dashboard/ai-workflows/_components/workflow-condition-node-content.tsx b/web/app/dashboard/ai-workflows/_components/workflow-condition-node-content.tsx index f1a2a08..e4cb45a 100644 --- a/web/app/dashboard/ai-workflows/_components/workflow-condition-node-content.tsx +++ b/web/app/dashboard/ai-workflows/_components/workflow-condition-node-content.tsx @@ -5,6 +5,7 @@ import { cn } from "@/lib/utils" import { useWorkflowBranchSelection } from "./workflow-branch-selection" import { createConditionBranchID, + isBranchRowActionTarget, normalizeNodeConfig, type WorkflowConditionBranch, } from "./workflow-utils" @@ -99,6 +100,9 @@ function WorkflowConditionBranchRow({ )} onPointerDownCapture={(event) => { event.stopPropagation() + if (isBranchRowActionTarget(event.target)) { + return + } onSelect() }} onMouseDownCapture={(event) => { diff --git a/web/app/dashboard/ai-workflows/_components/workflow-utils.test.mjs b/web/app/dashboard/ai-workflows/_components/workflow-utils.test.mjs index 64486fc..35b68fb 100644 --- a/web/app/dashboard/ai-workflows/_components/workflow-utils.test.mjs +++ b/web/app/dashboard/ai-workflows/_components/workflow-utils.test.mjs @@ -262,6 +262,23 @@ describe("workflow variable display helpers", () => { }) }) +describe("workflow branch interaction helpers", () => { + it("detects branch row action targets inside buttons", async () => { + const { isBranchRowActionTarget } = await loadModule() + + assert.equal(isBranchRowActionTarget({ + closest(selector) { + return selector === "button" ? {} : null + }, + }), true) + assert.equal(isBranchRowActionTarget({ + closest() { + return null + }, + }), false) + }) +}) + describe("workflow definition mutations", () => { it("updates node data without changing unrelated nodes", async () => { const { updateWorkflowNodeData } = await loadModule() diff --git a/web/app/dashboard/ai-workflows/_components/workflow-utils.ts b/web/app/dashboard/ai-workflows/_components/workflow-utils.ts index ed4bffc..e567f34 100644 --- a/web/app/dashboard/ai-workflows/_components/workflow-utils.ts +++ b/web/app/dashboard/ai-workflows/_components/workflow-utils.ts @@ -126,6 +126,11 @@ export function buildVariableSpecDisplay(variable: WorkflowVariableSpec): Workfl } } +export function isBranchRowActionTarget(target: EventTarget | null): boolean { + const maybeElement = target as { closest?: (selector: string) => Element | null } | null + return typeof maybeElement?.closest === "function" && maybeElement.closest("button") !== null +} + export function getNodeTitle( node: AIWorkflowDefinition["nodes"][number] | undefined, specs: AIWorkflowNodeSpec[] = []