Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: don't open the node settings panel when clicking a node in comment mode (#39500)

David Park3cbe49bf45c9
diff --git a/web/app/components/workflow/nodes/_base/__tests__/node.spec.tsx b/web/app/components/workflow/nodes/_base/__tests__/node.spec.tsx
index b4fd610e28b..5d963a9f550 100644
--- a/web/app/components/workflow/nodes/_base/__tests__/node.spec.tsx
+++ b/web/app/components/workflow/nodes/_base/__tests__/node.spec.tsx
@@ -2,7 +2,7 @@ import type { PropsWithChildren } from 'react'
import type { CommonNodeType } from '@/app/components/workflow/types'
import { fireEvent, screen } from '@testing-library/react'
import { renderWorkflowComponent } from '@/app/components/workflow/__tests__/workflow-test-env'
-import { BlockEnum, NodeRunningStatus } from '@/app/components/workflow/types'
+import { BlockEnum, ControlMode, NodeRunningStatus } from '@/app/components/workflow/types'
import BaseNode from '../node'
const mockHasNodeInspectVars = vi.fn()
@@ -161,6 +161,23 @@ describe('BaseNode', () => {
expect(selectWorkflowNode).toHaveBeenCalledWith('node-1')
})
+ it('should not select the node from the title button while in comment mode', async () => {
+ const { selectWorkflowNode } = await import('@/app/components/workflow/utils/node-navigation')
+
+ renderWorkflowComponent(
+ <BaseNode id="node-1" data={toNodeData(createData())}>
+ <div>Body</div>
+ </BaseNode>,
+ { initialStoreState: { controlMode: ControlMode.Comment } },
+ )
+
+ const node = screen.getByRole('button', { name: 'Node title' })
+
+ fireEvent.click(node)
+
+ expect(selectWorkflowNode).not.toHaveBeenCalled()
+ })
+
it('should keep header metadata outside the selectable button', () => {
renderWorkflowComponent(
<BaseNode
diff --git a/web/app/components/workflow/nodes/_base/node.tsx b/web/app/components/workflow/nodes/_base/node.tsx
index 342d1e84ab3..fc317f89b93 100644
--- a/web/app/components/workflow/nodes/_base/node.tsx
+++ b/web/app/components/workflow/nodes/_base/node.tsx
@@ -240,7 +240,13 @@ const BaseNode: FC<BaseNodeProps> = ({ id, data, children }) => {
type="button"
aria-label={data.title}
className="mr-1 flex min-w-0 grow appearance-none items-center rounded-md border-0 bg-transparent p-0 text-left focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
- onClick={() => selectWorkflowNode(id)}
+ onClick={() => {
+ // In comment mode, clicking a node should not open the node settings panel:
+ // the right-hand panel covers the canvas region where the comment is anchored.
+ // Mirrors the comment-mode guard in use-nodes-interactions' handleNodeClick.
+ if (controlMode === ControlMode.Comment) return
+ selectWorkflowNode(id)
+ }}
>
<BlockIcon className="mr-2 shrink-0" type={data.type} size="md" toolIcon={toolIcon} />
<div className="flex min-w-0 grow items-center system-sm-semibold-uppercase text-text-primary">