fix(frontend): Firefox clipboard fallback for permalink copying#9879
Draft
Nish2005karsh wants to merge 1 commit into
Draft
fix(frontend): Firefox clipboard fallback for permalink copying#9879Nish2005karsh wants to merge 1 commit into
Nish2005karsh wants to merge 1 commit into
Conversation
Closes marimo-team#3912 The "Create WebAssembly link"/molab permalink actions await an async readCode() before copying the resulting URL. In Firefox this consumes the transient user activation that navigator.clipboard.writeText requires, so the write rejects and the permalink is never copied. Add a hidden-textarea + document.execCommand("copy") fallback to the shared copyToClipboard util, which has laxer user-activation requirements and so succeeds after an await. Because every copy in the app routes through this util, the fix applies to permalinks and all other copy actions. The user's existing selection is preserved and restored, and window.prompt remains as the last resort. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
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.
This pull request was authored by a coding agent.
Fixes #3912
Problem
"Create permalink" / "Create WebAssembly link" doesn't copy to the clipboard in Firefox. The permalink actions in
useNotebookActions.tsxawait readCode()before callingcopyToClipboard(url). In Firefox, theawaitconsumes the transient user activation thatnavigator.clipboard.writeText()requires, so the write rejects and nothing reaches the clipboard.Fix
Fixed centrally in the shared
copyToClipboardutil (every copy in the app routes through it, so this covers permalinks and all other copy actions). New fallback chain:navigator.clipboard.writefor rich text/HTML — unchangednavigator.clipboard.writeText— modern pathtextarea+document.execCommand("copy")— has laxer user-activation requirements, so it succeeds in Firefox after anawait. The user's existing selection is saved and restored so it's invisible.window.prompt— last resort (unchanged behavior, now reached less often)document.execCommand("copy")is already used elsewhere in the codebase (cell-context-menu.tsx,vscode-bindings.ts), so this is consistent with existing patterns.Tests
Added 4 unit tests to
copy.test.tscovering:writeTextsuccess, the FirefoxwriteText-rejects →execCommandfallback, the no-navigator.clipboardcase, and falling through towindow.promptwhen both fail.pnpm --filter @marimo-team/frontend test src/utils/__tests__/copy.test.ts→ 14 passed