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(web): keep copy tooltip visible after click (#42789)

yyh9c210ea670c1
diff --git a/web/app/components/base/copy-feedback/__tests__/index.browser.spec.tsx b/web/app/components/base/copy-feedback/__tests__/index.browser.spec.tsx
new file mode 100644
index 00000000000..9e72245f765
--- /dev/null
+++ b/web/app/components/base/copy-feedback/__tests__/index.browser.spec.tsx
@@ -0,0 +1,24 @@
+import { page } from 'vite-plus/test/browser'
+import { render } from 'vitest-browser-react'
+import { CopyFeedback } from '..'
+
+it('keeps the copied tooltip visible after clicking the copy button', async () => {
+ const writeText = vi.spyOn(navigator.clipboard, 'writeText').mockResolvedValue(undefined)
+
+ try {
+ const screen = await render(<CopyFeedback content="test content" />)
+ const copyButton = screen.getByRole('button', { name: 'common.operation.copy' })
+
+ await copyButton.hover()
+ await expect.element(page.getByText('common.operation.copy')).toBeVisible()
+ await copyButton.click()
+
+ await expect.element(page.getByText('common.operation.copied')).toBeVisible()
+ await expect
+ .element(screen.getByRole('button', { name: 'common.operation.copied' }))
+ .toBeVisible()
+ expect(writeText).toHaveBeenCalledExactlyOnceWith('test content')
+ } finally {
+ writeText.mockRestore()
+ }
+})
diff --git a/web/app/components/base/copy-feedback/index.tsx b/web/app/components/base/copy-feedback/index.tsx
index 47c4d959eb3..c6b46ee5cb5 100644
--- a/web/app/components/base/copy-feedback/index.tsx
+++ b/web/app/components/base/copy-feedback/index.tsx
@@ -40,6 +40,7 @@ export function CopyFeedback({
return (
<Tooltip>
<TooltipTrigger
+ closeOnClick={false}
render={
<IconButton aria-label={safeText} className={className} onClick={handleCopy}>
<span