Skip to content

Handle clipboard write rejection in TerminalBlock - #8783

Open
ShakilUrRehman21 wants to merge 1 commit into
reactjs:mainfrom
ShakilUrRehman21:fix-terminal-copy-error
Open

ShakilUrRehman21 wants to merge 1 commit into
reactjs:mainfrom
ShakilUrRehman21:fix-terminal-copy-error

Conversation

@ShakilUrRehman21

Copy link
Copy Markdown
Contributor

Summary

In src/components/MDX/TerminalBlock.tsx, the Copy button called window.navigator.clipboard.writeText(...) without awaiting it or catching rejections, and immediately called setCopied(true).

If clipboard access is denied or unavailable, this caused an unhandled promise rejection and falsely displayed "Copied".

This PR awaits navigator.clipboard.writeText inside a try/catch block so setCopied(true) only runs when the copy succeeds and rejections are handled safely.

How was this tested?

  • Ran npx tsc --noEmit (passed with 0 errors).
  • Verified Prettier formatting on src/components/MDX/TerminalBlock.tsx.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Five Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/404 118.91 KB (🟢 -199 B) 234.09 KB
/500 118.92 KB (🟢 -199 B) 234.09 KB
/[[...markdownPath]] 121.4 KB (🟢 -199 B) 236.58 KB
/errors 119.16 KB (🟢 -199 B) 234.34 KB
/errors/[errorCode] 119.13 KB (🟢 -199 B) 234.31 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

This branch was successfully deployed

1 active deployment
Preview — a66ec57f Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant