fix: add null check for navigator.clipboard across all copy-to-clipboard calls (#2114)#3813
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📣 Social Copy GeneratorGenerate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.
|
@copilotkit/a2ui-renderer
@copilotkitnext/angular
copilotkit
@copilotkit/core
@copilotkit/react-core
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/web-inspector
commit: |
Add null checks for navigator.clipboard across all copy-to-clipboard calls to prevent TypeError in non-localhost environments where the Clipboard API is unavailable. The copied indicator now only appears after a confirmed successful write, preventing false positive UX feedback when the clipboard API is missing or the write fails.
…plication Address review feedback: extract the repeated clipboard availability check + writeText + error handling pattern into a shared copyToClipboard() utility in @copilotkit/shared. All 9 call sites across angular, react-core, and react-ui now use the shared utility instead of duplicating the same code block.
|
Addressed the feedback about duplicated clipboard code blocks. What changed: Extracted a shared
All 9 call sites across Added unit tests for the utility itself in |
The CopyButton in react-core was showing the "copied" checkmark based on an independent clipboard availability check rather than the actual copy result. This meant a failed copy (e.g. permission denied) would still show the success indicator. Now the onClick handler returns the boolean from copyToClipboard, and handleClick uses that to drive the UI state. Also removes unsafe type casts of onClick to Promise<void>.
Fixes #2114
Red-green tested locally.