fall back to execCommand when clipboard API is unavailable - #23
Merged
Conversation
pingsutw
approved these changes
Jul 14, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the clipboard copy behavior in the UI so copy actions don’t throw on HTTP (non-secure) deployments and remain SSR-safe by routing global access through windowUtils.
Changes:
- Makes
useCopyToClipboardasynchronous and wraps clipboard operations in error handling. - Uses
navigator.clipboard.writeTextin secure contexts and falls back to a hidden<textarea>+document.execCommand('copy')otherwise. - Switches direct global access to
getWindow()/getDocument()/getNavigator()helpers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Carina Ursu <carina@union.ai>
ursucarina
force-pushed
the
carina/cppolyfill
branch
from
July 14, 2026 19:27
3ce8129 to
549aff5
Compare
ursucarina
enabled auto-merge
July 14, 2026 19:31
pingsutw
approved these changes
Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
navigator.clipboardis only available in secure contexts (HTTPSorlocalhost), so on deployments served over plain HTTP the copy button threwUncaught TypeError: Cannot read properties of undefined (reading 'writeText'). This makesuseCopyToClipboardasync and resilient: it uses the native Clipboard API when available in a secure context, otherwise falls back to a hidden <textarea> + document.execCommand('copy'), and wraps everything in try/catch so a copy failure can never throw. Window/document/navigator access goes through the SSR-safe getWindow()/getDocument()/getNavigator() helpers to satisfy the no-restricted-globals lint rule.