-
Notifications
You must be signed in to change notification settings - Fork 25
fix: copying created links in Safari #1594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f013794 to
fb5d67b
Compare
There was a problem hiding this 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
useCopyLinkcomposable that handles link creation and clipboard copying in a single user interaction - Deprecated the existing
useClipboardcomposable in favor of using VueUse's implementation directly or the newuseCopyLinkfor links - Removed the callback pattern from
CreateLinkModalsince 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.
fb5d67b to
525230b
Compare
kulmann
left a comment
There was a problem hiding this 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 🥳
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
fix: copying created links in Safari
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