Skip to content

Overlay code copy buttons without moving code - #1541

Merged
max-sixty merged 5 commits into
mainfrom
codex/code-block-copy
Oct 2, 2026
Merged

max-sixty merged 5 commits into
mainfrom
codex/code-block-copy

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

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.

This was written by Codex on behalf of max-sixty

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 leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@max-sixty
max-sixty merged commit ba1aceb into main Oct 2, 2026
4 checks passed
@max-sixty
max-sixty deleted the codex/code-block-copy branch October 2, 2026 01:02
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]>
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.

2 participants