langfuse icon indicating copy to clipboard operation
langfuse copied to clipboard

fix: cannot copy to clipboard in http or untrused https host(except localhost) (#6744)

Open XenoAmess opened this issue 7 months ago • 1 comments

What does this PR do?

Fixes # (issue)

https://github.com/langfuse/langfuse/issues/6744

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] Chore (refactoring code, technical debt, workflow improvements)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Refactor (does not change functionality, e.g. code style improvements, linting)
  • [ ] This change requires a documentation update

Mandatory Tasks

  • [x] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project (npm run prettier)
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my PR needs changes to the documentation
  • I haven't checked if my changes generate no new warnings (npm run lint)
  • I haven't added tests that prove my fix is effective or that my feature works
  • I haven't checked if new and existing unit tests pass locally with my changes

[!IMPORTANT] Fixes clipboard copy issue in non-secure contexts by introducing a fallback method in copyToClipboard and updating multiple components to use it.

  • Behavior:
    • Fixes clipboard copy issue in non-secure contexts by introducing copyToClipboard in clipboard.ts.
    • Replaces navigator.clipboard.writeText with copyToClipboard in publish-object-switch.tsx, useViewMutations.ts, CopyIdsPopover.tsx, CodeJsonViewer.tsx, Codeblock.tsx, MarkdownViewer.tsx, GenerationOutput.tsx, and PromptSelectionDialog.tsx.
  • Dependencies:
    • Adds copy-to-clipboard package to package.json.

This description was created by Ellipsis for 5b9adecf42bd0c5186b039b768d7c4aafbf2b653. You can customize this summary. It will automatically update as commits are pushed.

XenoAmess avatar May 08 '25 11:05 XenoAmess

also upgrade react18-json-view version, to active similar funcions in newer version of that repo. see: https://github.com/YYsuni/react18-json-view/commit/0bb956ed7e5fe55053c7abd81bc75f27965c4152

XenoAmess avatar May 08 '25 12:05 XenoAmess

Thanks so much for your contribution @XenoAmess! However, as we prefer to not include new dependencies and this branch was put up before, we accepted this contribution instead. Happy to mention you in release notes regardless if this is something you'd like? Many thanks.

marliessophie avatar Jun 11 '25 08:06 marliessophie