Repository navigation
Overlay code copy buttons without moving code - #1541
Merged
Merged
Conversation
Replace the copy-row clearance expectation with unchanged code geometry. Exercise touch copying with an accessible label and disable the hidden tooltip that overrides it.
leaf-agent
reviewed
Oct 2, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The always-visible touch copy button covers source text at the end of a horizontally scrolled one-line block. With a 390px viewport and the block at maximum scrollLeft, I measured the final five characters at x=313–351 and the button at x=318–362; their rectangles overlap. The new test checks that the button stays in the corner, but its sample lines start with whitespace and do not test whether source remains readable there. Please give the covered suffix a way to be seen and selected on touch, through placement or disclosure, and check a dense first line at the scroll limit.
Entering code by touch focuses its source and hides the corner overlay until focus leaves, so dense first lines and the end of horizontally scrolled lines remain readable and selectable. Reuse the shared focus owner to preserve authored tabindex and retire temporary focus stops on blur. Exercise a real touch tap and swipe, suffix hit testing and selection, restored keyboard access, and unchanged geometry. Add the source-focused touch state to the visual catalogue.
leaf-agent
approved these changes
Oct 2, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 3, 2026
#4738 deliberately gave every page code block a code line above and below its code (`padding: var(--code-line) …` in `browser/styles/components/reading.css`, 20px at the top), so a fence's source revealed under the composer's caret moves nothing. Its description says this "gives every code block 8px more room above its code". The nightly journey `test_code_copy_keeps_source_and_stays_beside_scrolling_and_revised_blocks` still pinned the old 12px for every block, so it has failed since that merge. The test now expects 20px for the page blocks, both on desktop and for the plain block on a phone. The numbered `lf-code` widget keeps its own 12px inset (`--lf-code-inset-block` in `packages/default/styles/code.css`), which #4738 didn't touch. The assertion still protects what #1541 added it for: Copy overlays the block and takes no room from it. No product code changes. The journey failed on current main with the same `'20px' == '12px'` assertion as the nightly run, and passes with this change (`uv run pytest tests/journeys/test_render_anchors.py::test_code_copy_keeps_source_and_stays_beside_scrolling_and_revised_blocks --run-nightly`). Closes #5175 — automated triage Co-authored-by: leaf-agent <[email protected]>
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.
The copy control reserved a blank row above each code block. Make it float over the upper-right corner, reveal it on hover or keyboard focus, and show it on touch. Entering code by touch hides the button so covered text can be read and selected; leaving the source restores it. Remove the added padding from plain blocks and
lf-code, and disable the hidden tooltip that masks the button's accessible name on touch.The browser test checks unchanged geometry, exact clipboard contents, scrolling, revisions, accessible copy feedback, and readable and selectable dense first lines on touch. It also checks native swiping and authored or temporary focus stops. Added matched visual states for hover, keyboard focus, and touch reading, and refreshed the gallery previews. Validation: all 1,492 tests and 189 runtime tests pass, as does lint. The visual catalogue checks 31 states; served startup profiles show no added code requests.