Skip to content

fix(web): restore "Copied" feedback state on copy buttons#35513

Merged
lyzno1 merged 1 commit intomainfrom
fix/clipboard-copied-state
Apr 23, 2026
Merged

fix(web): restore "Copied" feedback state on copy buttons#35513
lyzno1 merged 1 commit intomainfrom
fix/clipboard-copied-state

Conversation

@lyzno1
Copy link
Copy Markdown
Member

@lyzno1 lyzno1 commented Apr 23, 2026

Important

Fixes #35512.

Summary

useClipboard never flipped copied to true on a successful write, so every UI built on it (icon swap, Copy → Copied tooltip) was stuck on the pre-copy state. The most visible regression is the copy-icon next to the API endpoint URL on /datasets (Service API card), but this hook is shared by several surfaces.

CopyFeedback / CopyFeedbackNew also wired onMouseLeave={reset} on the click target, which would clear the "Copied" state the instant the cursor left the icon — even after fixing the hook, users could not read the confirmation.

Changes

  • web/hooks/use-clipboard.ts — call handleCopyResult(true) after a successful writeTextToClipboard, and after the prompt-fallback path when usePromptAsFallback is enabled.
  • web/app/components/base/copy-feedback/index.tsx — drop the onMouseLeave={reset} handler on both CopyFeedback and CopyFeedbackNew; rely on the hook's timer instead. Bump the timeout to 2000ms for these surfaces to match the KeyValueItem copy feedback used by the plugin Debug info popover.
  • web/app/components/base/copy-feedback/__tests__/index.spec.tsx — update the mouse-leave assertion to verify reset is not called (the timeout drives the revert now).

Screenshots

Before After
Clicking the copy icon copies the text, but the tooltip stays on Copy and the icon never swaps. Clicking copies the text, the icon swaps to the filled variant, and the tooltip shows Copied for ~2s before reverting.

Checklist

  • This change does not require a documentation update.
  • I understand that this PR may be closed in case there was no previous discussion or issues.
  • I've updated the existing test for each behavior change.
  • I've updated the documentation accordingly.
  • I ran pnpm exec vp staged on the touched files.

Made with Cursor

…d write

- `useClipboard` never called `handleCopyResult(true)` on success, so the
  `copied` flag was permanently `false`. Any UI depending on it (copy icon
  swap, "Copy → Copied" tooltip) was stuck on the pre-copy state.
- `CopyFeedback` / `CopyFeedbackNew` wired `onMouseLeave={reset}` on the
  click target, which would wipe the "Copied" state the instant the cursor
  left the icon — even with the hook fix, users could not read the
  confirmation. Remove it and rely on the hook's own timer (bumped to
  2000 ms to match `KeyValueItem`'s copy feedback in the plugin Debug
  info popover).

Fixes #35512

Made-with: Cursor
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 23, 2026
@github-actions github-actions Bot added the web This relates to changes on the web. label Apr 23, 2026
@dosubot dosubot Bot added the javascript Pull requests that update javascript code label Apr 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.57%. Comparing base (61c0948) to head (a61ba21).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #35513   +/-   ##
=======================================
  Coverage   85.57%   85.57%           
=======================================
  Files        4440     4440           
  Lines      207715   207715           
  Branches    38804    38804           
=======================================
+ Hits       177754   177755    +1     
+ Misses      26841    26840    -1     
  Partials     3120     3120           
Flag Coverage Δ
dify-ui 93.01% <ø> (ø)
web 86.51% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 23, 2026
@lyzno1 lyzno1 enabled auto-merge April 23, 2026 06:36
@lyzno1 lyzno1 added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit 91a1df9 Apr 23, 2026
33 checks passed
@lyzno1 lyzno1 deleted the fix/clipboard-copied-state branch April 23, 2026 06:50
asukaminato0721 pushed a commit to asukaminato0721/dify that referenced this pull request Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Copy button tooltip never switches to "Copied" after clicking

2 participants