fix(web): restore "Copied" feedback state on copy buttons#35513
Merged
Conversation
…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
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
hyoban
approved these changes
Apr 23, 2026
asukaminato0721
pushed a commit
to asukaminato0721/dify
that referenced
this pull request
Apr 24, 2026
fatelei
pushed a commit
that referenced
this pull request
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Fixes #35512.
Summary
useClipboardnever flippedcopiedtotrueon a successful write, so every UI built on it (icon swap,Copy → Copiedtooltip) 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/CopyFeedbackNewalso wiredonMouseLeave={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— callhandleCopyResult(true)after a successfulwriteTextToClipboard, and after the prompt-fallback path whenusePromptAsFallbackis enabled.web/app/components/base/copy-feedback/index.tsx— drop theonMouseLeave={reset}handler on bothCopyFeedbackandCopyFeedbackNew; rely on the hook's timer instead. Bump the timeout to2000msfor these surfaces to match theKeyValueItemcopy feedback used by the plugin Debug info popover.web/app/components/base/copy-feedback/__tests__/index.spec.tsx— update the mouse-leave assertion to verifyresetis not called (the timeout drives the revert now).Screenshots
Copyand the icon never swaps.Copiedfor ~2s before reverting.Checklist
pnpm exec vp stagedon the touched files.Made with Cursor