mirror of
https://github.com/langgenius/dify.git
synced 2026-07-25 13:38:31 +08:00
fix: don't open the node settings panel when clicking a node in comment mode (#39500)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
dd19b4ff79
commit
3cbe49bf45
@ -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
|
||||
|
||||
@ -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">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user