fix(code-block): move copy action into toolbar and preserve keyboard accessibility#14024
Merged
sfc-gh-bnisco merged 1 commit intodevelopfrom Feb 20, 2026
Merged
Conversation
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
✅ PR preview is ready!
|
Collaborator
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
121950a to
2c9e988
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors code-block copy UI to use a shared toolbar action (via ToolbarAction + useCopyToClipboard) instead of a bespoke overlay button, and updates unit/E2E tests accordingly.
Changes:
- Added
CodeBlockCopyToolbarand replaced existing code-block copy button usage in code block renderers. - Updated CodeBlock styling to show the copy action via a toolbar wrapper on hover/focus-within.
- Updated unit tests to use accessible role/name queries and refreshed Playwright snapshot baselines.
Reviewed changes
Copilot reviewed 7 out of 46 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| frontend/lib/src/components/shared/StreamlitMarkdown/StreamlitMarkdown.test.tsx | Updates markdown code-copy test to query the copy control by accessible role/name. |
| frontend/lib/src/components/elements/CodeBlock/styled-components.ts | Replaces copy-button overlay styling with toolbar wrapper styling and hover/focus-within behavior. |
| frontend/lib/src/components/elements/CodeBlock/StreamlitSyntaxHighlighter.tsx | Switches syntax highlighter code blocks to render CodeBlockCopyToolbar for non-empty content. |
| frontend/lib/src/components/elements/CodeBlock/StreamlitSyntaxHighlighter.test.tsx | Adds coverage for presence/absence of the copy toolbar action based on code content. |
| frontend/lib/src/components/elements/CodeBlock/StreamlitErrorCodeBlock.tsx | Switches error code blocks to render CodeBlockCopyToolbar when copy is applicable. |
| frontend/lib/src/components/elements/CodeBlock/StreamlitErrorCodeBlock.test.tsx | Updates copy-button assertions to use accessible role/name queries. |
| frontend/lib/src/components/elements/CodeBlock/CodeBlockCopyToolbar.tsx | New component that renders a ToolbarAction copy control backed by useCopyToClipboard. |
| e2e_playwright/snapshots/linux/st_container_test/st_container-content_width[webkit].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_container_test/st_container-content_width[firefox].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_container_test/st_container-content_width[chromium].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-long-wrap[chromium].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-long-single-word-string-wrap[webkit].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-long-single-word-string-wrap[chromium].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-long-single-word-string-no-wrap[firefox].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-long-single-word-string-no-wrap[chromium].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-long-numbers-wrap[chromium].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-hover_copy[light_theme-webkit].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-hover_copy[light_theme-firefox].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-hover_copy[light_theme-chromium].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-hover_copy[dark_theme-webkit].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-hover_copy[dark_theme-firefox].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-hover_copy[dark_theme-chromium].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-height_container[chromium].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-form_container[chromium].png | Updated snapshot baseline after UI changes. |
| e2e_playwright/snapshots/linux/st_code_test/st_code-columns[chromium].png | Updated snapshot baseline after UI changes. |
frontend/lib/src/components/elements/CodeBlock/styled-components.ts
Outdated
Show resolved
Hide resolved
2c9e988 to
de55d66
Compare
Replace the absolute copy overlay in code and error code blocks with a shared toolbar action so long unwrapped lines no longer cover the copy control. Preserve copy feedback states and add tests for toolbar copy visibility with empty-content guardrails.
de55d66 to
f6c8618
Compare
sfc-gh-nbellante
approved these changes
Feb 20, 2026
This was referenced Feb 20, 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.

Describe your changes
Screenshot or video (only for visual changes)
Please see the updated e2e snapshots.
GitHub Issue Link (if applicable)
Fixes #12958
Testing Plan
test_copy_action_keyboard_accessibilityto verify keyboard navigation to code blocks and copy buttonsContribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
Co-authored-by: Raymond [email protected]
Co-authored-by: Daniel Derefaka [email protected]
Co-authored-by: Tyson Cung [email protected]
Co-authored-by: Manas Vardhan [email protected]
Co-authored-by: Nilesh Hadalgi [email protected]