Uh oh!
There was an error while loading. Please reload this page.
fix(web): add clipboard fallback for non-HTTPS contexts - #32702
fix(web): add clipboard fallback for non-HTTPS contexts#32702GautamKumarOffical wants to merge 1 commit into
Conversation
Adds a fallback using document.execCommand('copy') when
navigator.clipboard is not available (e.g., localhost without HTTPS).
Fixesanomalyco#32664This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
The following comment was made by an LLM, it may be inaccurate: Found 1 potentially related PR: fix(app): clipboard fallback so copy buttons work in non-secure contexts This PR addresses the same issue (clipboard fallback for non-secure/non-HTTPS contexts) but targets the |
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Summary
Adds a clipboard fallback for non-HTTPS contexts (e.g., localhost without HTTPS).
Fixes#32664
Problem
The copy-to-clipboard button for code blocks doesn't work in
opencode webwhen opened on localhost without HTTPS. This is becausenavigator.clipboardrequires HTTPS in most browsers.Solution
Added a fallback using
document.execCommand('copy')whennavigator.clipboardis not available:navigator.clipboard.writeText()first (works with HTTPS)document.execCommand('copy')Testing