fix: use useClipboard hook in CodeBlockComponent to fix clipboard on non-secure contexts#28003
Open
harsh-vador wants to merge 1 commit intomainfrom
Open
fix: use useClipboard hook in CodeBlockComponent to fix clipboard on non-secure contexts#28003harsh-vador wants to merge 1 commit intomainfrom
harsh-vador wants to merge 1 commit intomainfrom
Conversation
…non-secure contexts
Code Review ✅ ApprovedReplaces manual clipboard handling with the OptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
Contributor
|
Contributor
🟡 Playwright Results — all passed (17 flaky)✅ 4068 passed · ❌ 0 failed · 🟡 17 flaky · ⏭️ 86 skipped
🟡 17 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
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.



…
Describe your changes:
Summary
CodeBlockComponentusednavigator.clipboard.writeText()directly with a silentcatch— onhttp://(AUT/non-secure context)window.isSecureContextisfalse, the write silently fails,setCopiednever fires, and E2E tests see an empty clipboarduseClipboardhook (same pattern asCopyLinkButton) which has adocument.execCommandfallback for non-secure contextscopyAndGetClipboardTextPlaywright utility: replaced fixed 300ms wait + textarea paste hack with a sentinel-basedexpect.poll— writes a known sentinel before clicking, pollsnavigator.clipboard.readText()until the value changes, eliminating races from pre-populated clipboard or slow async writesServiceDocPanel.test.tsx: addedwindow.isSecureContext = truemock, removed timer implementation-detail tests (now owned byuseClipboardhook), kept behavioral assertionsScreen.Recording.2026-05-09.at.1.20.53.AM.mov
I worked on ... because ...
Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
Unit tests
Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.