[PR #31308] refactor(web): extract useCopyToClipboard hook to reduce duplication #33177

Closed
opened 2026-02-21 20:52:48 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/31308

State: closed
Merged: Yes


Closes #31314

Summary

I noticed the copy-to-clipboard logic was duplicated in 4 different components, so I extracted it into a reusable useCopyToClipboard hook.

Changes:

  • Created hooks/use-copy-to-clipboard.ts with shared logic
  • Refactored CopyIcon, CopyFeedback, CopyFeedbackNew, and InputWithCopy to use the new hook
  • Reduced ~67 lines of duplicate code

Test plan

  • pnpm lint:fix passes
  • pnpm type-check:tsgo passes
  • Manual testing: verify copy functionality works as before in each component
**Original Pull Request:** https://github.com/langgenius/dify/pull/31308 **State:** closed **Merged:** Yes --- Closes #31314 ## Summary I noticed the copy-to-clipboard logic was duplicated in 4 different components, so I extracted it into a reusable `useCopyToClipboard` hook. **Changes:** - Created `hooks/use-copy-to-clipboard.ts` with shared logic - Refactored `CopyIcon`, `CopyFeedback`, `CopyFeedbackNew`, and `InputWithCopy` to use the new hook - Reduced ~67 lines of duplicate code ## Test plan - [x] `pnpm lint:fix` passes - [x] `pnpm type-check:tsgo` passes - [ ] Manual testing: verify copy functionality works as before in each component
yindo added the pull-request label 2026-02-21 20:52:48 -05:00
yindo closed this issue 2026-02-21 20:52:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33177