Skip to content

fix: copy link without ClipboardItem and keep the clipboard when there is no single link - #3871

Merged
AlexAndBear merged 1 commit into
mainfrom
fix/copy-link-clipboard
Oct 20, 2026
Merged

AlexAndBear merged 1 commit into
mainfrom
fix/copy-link-clipboard

Conversation

@AlexAndBear

@AlexAndBear AlexAndBear commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Description

  • ClipboardItem check (The ClipboardItem check in copy link is always true #3863): typeof ClipboardItem && navigator.clipboard.write was always true on its first part and threw where navigator.clipboard is missing (insecure context). It now checks typeof ClipboardItem !== 'undefined' && navigator.clipboard?.write, so browsers without ClipboardItem use the fallback and the link is still created without clipboard access.
  • Legacy copy fallback: useClipboard({ legacy: true }) lets the fallback copy through execCommand when the Clipboard API is missing, like the other copy buttons do. The secure-context path is unchanged.
  • Keep the clipboard (Creating several links at once overwrites the clipboard with empty text #3864): when there is no single link text (several links, or the creation failed), the clipboard write is now rejected before anything is written, so the previous clipboard content stays instead of being replaced by an empty string. The console warning only appears when a link text could not be copied.

Related Issue

How Has This Been Tested?

  • test environment: unit tests (Vitest), browser tests (Playwright) against a local OpenCloud
  • test case 1: unit: no ClipboardItem uses the fallback and shows the copied message; no navigator.clipboard still creates and copies the link; several links and a failed creation keep the previous clipboard content (all fail without the fix)
  • test case 2: browser: a failed link creation (500, and a real 400 without password) emptied the clipboard on main and keeps it with the fix, with and without the create link modal
  • test case 3: browser: without ClipboardItem, and without navigator.clipboard, the link is created and copied with the fix (main showed an error or did nothing in the modal)
  • test case 4: browser: add link in the sharing sidebar with and without enforced password, copy link and password, the copy button in the links panel, copy permanent link
  • test case 5: creating several links at once is not reachable in the UI today, so that case is covered by the unit test only

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

@tammi-23 tammi-23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@AlexAndBear
AlexAndBear merged commit 3edbff8 into main Oct 20, 2026
28 checks passed
@AlexAndBear
AlexAndBear deleted the fix/copy-link-clipboard branch October 20, 2026 11:50
@openclouders openclouders mentioned this pull request Oct 20, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Creating several links at once overwrites the clipboard with empty text The ClipboardItem check in copy link is always true

2 participants