Skip to content

Stand a pin on the drawn part it comments on, not the drawing's edge - #1236

Merged
max-sixty merged 4 commits into
mainfrom
fix-svg-comment-marker-placement
Sep 26, 2026
Merged

max-sixty merged 4 commits into
mainfrom
fix-svg-comment-marker-placement

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

A comment on one shape of an inline SVG drawing put its pin at the drawing's right edge, beside a different shape. In the case that prompted this, a comment on the first of four thumbnails in a wide figure pinned beside the fourth, and its card opened over that one.

A shape inside an <svg> has no CSS box, and Chrome won't anchor to one: anchor-name on a <g> or <rect> falls back in Chrome 154. So its margin row anchors through the drawing. The layout pass already moved the row down to the shape's top with an inset. The pin posture from #1164 never did the same horizontally, so the pin stood --pin-inset inside the drawing's right edge.

The layout pass now reads the box the target's shown parts cover together (shownExtent in margin-layout.js), and the row stands at that box's top-right corner whatever it anchors through. The pass writes the corner as two insets from the anchor's box: --lf-inset-top (renamed from --lf-inset) and --lf-inset-right, which theme.css adds to the pin's right. The visibility check clips the same box by the target's own scrollers, for the top line and the pin's right edge alike, and packing uses its right edge. The same holds for a target anchored through a shadow host and for a display: contents target, which anchors through its first part but stands at the corner of all of them. Whether a row stands in the rail or as a pin is still decided by how far the whole figure reaches.

Two browser tests pin the behavior. test_a_pin_on_one_shape_of_a_drawing_stands_on_that_shape comments on two shapes of a wide drawing and requires each pin inside its own shape; on main the left shape's pin stands at x≈1347 against a shape ending at x≈402. test_a_pin_on_a_contents_target_stands_at_its_last_part covers a display: contents target with side-by-side parts, which an intermediate version of this branch withheld. The glossary, packages.md and page-authoring.md now say a pin stands inside its target's corner, and on a figure at the corner of the part a comment names.

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

max-sixty and others added 3 commits September 26, 2026 10:05
A shape inside an inline SVG has no CSS box, so its margin row anchors
through the <svg>. The row already took the shape's top from an inset;
as a pin it still took the drawing's right edge, so a comment on the
first of four thumbnails stood beside the fourth. The layout pass now
reads the target's corner inside its anchor as a top and a right inset,
and the pin stands `--pin-inset` inside the target's own right edge.
The same holds for a target reached through a shadow host or a
`display: contents` target's first part.

The new browser test comments on the left and right shapes of a wide
drawing and requires each pin inside its own shape; on the old runtime
the left shape's pin stands at the drawing's right edge.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The layout pass read an inset from the anchor's box, then added it back
wherever it needed the target's top or right edge. It now reads the
target's corner once (`cornerOf`); visibility and packing use it
directly, and the insets the stylesheet takes are written from it. No
behavior moves.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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.

A visible multi-part target can lose its pin because the visibility check still uses only the box that supplies its CSS anchor.

A display: contents target anchors through its first part, but its pin
now stands at the corner of all its parts; the pin check still measured
against the first part's box, so two side-by-side parts withheld a pin
both of whose parts were in view. The pass now reads the box the
target's shown parts cover together (shownExtent) and clips that by the
target's own scrollers, for the top line and the pin's right edge alike.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit a649111 into main Sep 26, 2026
7 checks passed
@max-sixty
max-sixty deleted the fix-svg-comment-marker-placement branch September 26, 2026 19:40
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