Skip to content

Conversation

@JammingBen
Copy link
Contributor

@JammingBen JammingBen commented Nov 11, 2025

For Safari to copy a newly created link to the clipboard, it requires that the link is created within the same user interaction as the clipboard write. This refactors the copying of links to do exactly that.

See https://wolfgangrittner.dev/how-to-use-clipboard-api-in-safari/ and https://developer.apple.com/forums/thread/691873

See c204065 for the actual fix.

fixes #1169

@JammingBen JammingBen self-assigned this Nov 11, 2025
@JammingBen JammingBen force-pushed the fix/safari-link-copy branch 6 times, most recently from f013794 to fb5d67b Compare November 11, 2025 14:57
@JammingBen JammingBen marked this pull request as ready for review November 11, 2025 15:13
Copilot AI review requested due to automatic review settings November 11, 2025 15:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors clipboard operations for link creation to support Safari's clipboard API requirements. Safari requires that clipboard writes occur within the same user interaction as the triggering event, so the link creation logic is now embedded directly within the clipboard operation instead of happening before it.

Key Changes:

  • Created a new useCopyLink composable that handles link creation and clipboard copying in a single user interaction
  • Deprecated the existing useClipboard composable in favor of using VueUse's implementation directly or the new useCopyLink for links
  • Removed the callback pattern from CreateLinkModal since copying is now handled internally

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/web-pkg/src/composables/links/useCopyLink.ts New composable implementing Safari-compatible clipboard operations for link creation
packages/web-pkg/src/composables/links/index.ts Exports the new useCopyLink composable
packages/web-pkg/src/composables/clipboard/useClipboard.ts Added deprecation notice to existing clipboard composable
packages/web-pkg/src/composables/actions/files/useFileActionsCreateLink.ts Refactored to use new useCopyLink composable, removed proceedResult function
packages/web-pkg/src/composables/actions/files/useFileActionsCopyPermanentLink.ts Updated to use VueUse's useClipboard directly instead of custom implementation
packages/web-pkg/src/components/CreateLinkModal.vue Converted to script setup, removed callback prop, integrated useCopyLink
packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCreateLink.spec.ts Removed test assertions for removed functionality
packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyPermanentLink.spec.ts Updated mock to use VueUse's useClipboard API
packages/web-pkg/tests/unit/components/CreateLinkModal.spec.ts Removed callback-related tests, added type assertions for Vue internals

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

For Safari to copy a newly created link to the clipboard, it requires that the link is created within the same user interaction as the clipboard write. This refactors the copying of links to do exactly that.
Copy link
Contributor

@kulmann kulmann left a comment

Choose a reason for hiding this comment

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

Super nice to have it working finally 🥳

@JammingBen JammingBen merged commit 9596355 into main Nov 13, 2025
28 checks passed
@JammingBen JammingBen deleted the fix/safari-link-copy branch November 13, 2025 12:38
@JammingBen
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
stable-4.2

Questions ?

Please refer to the Backport tool documentation

openclouders pushed a commit that referenced this pull request Nov 13, 2025
@openclouders openclouders mentioned this pull request Nov 13, 2025
1 task
ScharfViktor added a commit that referenced this pull request Nov 13, 2025
ScharfViktor added a commit that referenced this pull request Nov 13, 2025
@openclouders openclouders mentioned this pull request Dec 15, 2025
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.

Public link not copied to clipboard in Safari

3 participants