Repository navigation
fix(clipboard): handle fallback copy failures and errors (#384) - #392
Merged
Merged
Conversation
anurag629
requested changes
Nov 5, 2026
anurag629
left a comment
Member
There was a problem hiding this comment.
Hey @bhushan4work, nice work, the shared helper checks what execCommand('copy') returns and catches a throw, so both Copy buttons and the Ctrl/Cmd+Shift+C shortcut in ExportBar.tsx, and the button in FixItButton.tsx, only say it worked when it did, which is what I asked for on #384.
Two small things before I can merge:
src/lib/clipboard.ts:41exports the helper a second time ascopyTextToClipboard, but nothing imports that name (ExportBar.tsxrenames it on import), so please drop that line.- Some of the guards in the fallback are only there for the mocked
documentin the tests. Right afterappendChildthe textarea's parent is alwaysdocument.body, so thefinallyat :28 only needsdocument.body.removeChild(ta), without theparentNodecheck and itselse if. Thetypeof document.createElement === 'function'check at :18 can go too, sincetypeof document !== 'undefined'already covers the server.
Everything else looks good.
Collaborator
Author
|
@anurag629 I have pushed the desired changes . could u plz run a final review before merge |
anurag629
approved these changes
Nov 6, 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.
description
fix clipboard failure handling in
exportbar.tsxandfixitbutton.tsx.add a shared clipboard helper that checks the result of
document.execCommand('copy'), handles thrown exceptions, and cleans up the temporary textarea.show success notifications only when copying succeeds. display an error notification when both clipboard methods fail.
closes #384
how i tested this
npx vitest run tests/editor/export-bar.test.ts tests/editor/export-bar-copy.test.ts tests/components/fix-it-button.test.ts tests/lib/clipboard.test.ts(all 19 tests passed)npx tsc --noEmit(passed with 0 errors)ai assistance
none
type of change
screenshots
not applicable.
checklist
devnpm run checkpassesnpm run testpassesnpm run dev