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.

refactor(web): keep copy id events on the button (#40247)

yyh465dab2eed06
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index 0ae9a3ee624..705ebc84533 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -4825,22 +4825,6 @@
"count": 5
}
},
- "web/app/components/workflow/nodes/tool/components/__tests__/copy-id.spec.tsx": {
- "jsx_a11y/click-events-have-key-events": {
- "count": 1
- },
- "jsx_a11y/no-static-element-interactions": {
- "count": 1
- }
- },
- "web/app/components/workflow/nodes/tool/components/copy-id.tsx": {
- "jsx_a11y/click-events-have-key-events": {
- "count": 1
- },
- "jsx_a11y/no-static-element-interactions": {
- "count": 1
- }
- },
"web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/index.tsx": {
"typescript/no-explicit-any": {
"count": 1
diff --git a/web/app/components/workflow/nodes/tool/components/__tests__/copy-id.spec.tsx b/web/app/components/workflow/nodes/tool/components/__tests__/copy-id.spec.tsx
index 6d1b5455981..de88d76daf9 100644
--- a/web/app/components/workflow/nodes/tool/components/__tests__/copy-id.spec.tsx
+++ b/web/app/components/workflow/nodes/tool/components/__tests__/copy-id.spec.tsx
@@ -39,15 +39,20 @@ describe('tool/copy-id', () => {
expect(trigger).toHaveAccessibleName('appOverview.overview.appInfo.embedded.copy')
})
- it('should stop click propagation from the outer wrapper', () => {
+ it('should stop click propagation from the copy button', () => {
const handleParentClick = vi.fn()
- const { container } = render(
- <div onClick={handleParentClick}>
- <CopyId content="tool-123" />
- </div>,
- )
+ render(<CopyId content="tool-123" />)
+ document.body.addEventListener('click', handleParentClick)
- fireEvent.click(container.querySelector('.inline-flex') as HTMLElement)
+ act(() => {
+ fireEvent.click(
+ screen.getByRole('button', {
+ name: 'appOverview.overview.appInfo.embedded.copy',
+ }),
+ )
+ vi.advanceTimersByTime(100)
+ })
+ document.body.removeEventListener('click', handleParentClick)
expect(handleParentClick).not.toHaveBeenCalled()
})
diff --git a/web/app/components/workflow/nodes/tool/components/copy-id.tsx b/web/app/components/workflow/nodes/tool/components/copy-id.tsx
index 999bc7dff49..69673d62496 100644
--- a/web/app/components/workflow/nodes/tool/components/copy-id.tsx
+++ b/web/app/components/workflow/nodes/tool/components/copy-id.tsx
@@ -30,11 +30,7 @@ const CopyFeedbackNew = ({ content }: Props) => {
: t(($) => $[`${prefixEmbedded}.copy`], { ns: 'appOverview' })) || ''
return (
- <div
- className="inline-flex w-full pb-0.5"
- onClick={(e) => e.stopPropagation()}
- onMouseLeave={onMouseLeave}
- >
+ <div className="inline-flex w-full pb-0.5" onMouseLeave={onMouseLeave}>
<Tooltip>
<TooltipTrigger
render={
@@ -42,7 +38,10 @@ const CopyFeedbackNew = ({ content }: Props) => {
type="button"
aria-label={tooltip}
className="group/copy flex w-full items-center gap-0.5 text-left"
- onClick={onClickCopy}
+ onClick={(event) => {
+ event.stopPropagation()
+ onClickCopy()
+ }}
>
<span className="w-0 grow cursor-pointer truncate system-2xs-regular text-text-quaternary group-hover:text-text-tertiary">
{content}