Skip to content

feat(viewer): land revealed inline comment highlight ~1/3 down the viewport#578

Merged
yumike merged 1 commit into
mainfrom
comment-highlight-scroll-position
Jun 24, 2026
Merged

feat(viewer): land revealed inline comment highlight ~1/3 down the viewport#578
yumike merged 1 commit into
mainfrom
comment-highlight-scroll-position

Conversation

@yumike

@yumike yumike commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Opening an inline-comment deep link (#comment-<id>), or stepping to an inline comment with n/p, now lands the highlighted passage about a third of the way down the viewport instead of dead-center — where the eye rests on arrival, with room above for the comment thread.

What changed

  • Inline-highlight reveal (both the deeplink path and the n/p keyboard-nav call site) switches from scrollIntoView({ block: "center" }) to block: "start".
  • rw-annotation gets scroll-margin-top: 33vh, so the highlight's top lands ~⅓ down the viewport.

This uses the browser-native scroll-margin mechanism (the codebase's existing idiom for scroll positioning — headings already use scroll-margin-top) rather than manual scrollTo math, so it works whether the window or an embedding host (Backstage) owns the scroll container. Page-level/resolved comment deeplinks are unchanged.

Testing

  • e2e asserts the deeplinked highlight lands ~⅓ down (verified empirically at ratio 0.331); the getting-started fixture is lengthened so the page genuinely scrolls and the 33vh offset actually engages.
  • The n/p nav test guards that the highlight is no longer centered.
  • Full viewer e2e + svelte-check pass.

🤖 Generated with Claude Code

…ewport

Opening an inline-comment deep link (#comment-<id>), or stepping to an inline
comment with n/p, now lands the highlighted passage about a third of the way
down the viewport instead of dead-center — where the eye rests on arrival, with
room above for the comment thread.

Switch the inline-highlight reveal (both the deeplink path and the n/p keyboard
nav call site) from scrollIntoView block:"center" to block:"start", and add
scroll-margin-top: 33vh to the rw-annotation highlight element. This uses the
browser-native scroll-margin mechanism (the codebase's existing idiom for
scroll positioning) rather than manual scrollTo math, so it works whether the
window or an embedding host owns the scroll container.

Tests: e2e asserts the deeplinked highlight lands ~1/3 down (the getting-started
fixture is lengthened so the page genuinely scrolls and 33vh engages); the n/p
nav test guards that the highlight is no longer centered.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yumike yumike merged commit 3ff26c2 into main Jun 24, 2026
18 checks passed
@yumike yumike deleted the comment-highlight-scroll-position branch June 24, 2026 03: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.

1 participant