fix(css): adjust hash link scroll margin for sticky breadcrumbs (#121) - #209
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
|
@greptile review |
🚀 Preview DeploymentYour documentation preview is ready! Preview URL: https://pr-209.comapeo-docs-82j.pages.dev 📦 Content: from This preview will update automatically when you push new commits to this PR. Built with commit d18a6d1 |
| :is(.theme-doc-markdown, .markdown) :target, | ||
| :is(.theme-doc-markdown, .markdown) .anchor { | ||
| scroll-margin-top: calc( | ||
| var(--ifm-navbar-height, 60px) + 2px + 45px + 0.75rem |
There was a problem hiding this comment.
The offset assumes the breadcrumb bar is always 45px tall, but its height is content-driven. When breadcrumbs wrap on a narrow screen or use longer localized labels, the bar becomes taller while this offset stays fixed. Hash navigation can therefore still place headings or footnotes behind the sticky breadcrumb. Derive the offset from the actual height or account for wrapped breadcrumbs.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/css/custom.css
Line: 484
Comment:
**Fixed Height Misses Wrapping**
The offset assumes the breadcrumb bar is always 45px tall, but its height is content-driven. When breadcrumbs wrap on a narrow screen or use longer localized labels, the bar becomes taller while this offset stays fixed. Hash navigation can therefore still place headings or footnotes behind the sticky breadcrumb. Derive the offset from the actual height or account for wrapped breadcrumbs.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
@greptile review Addressed: Replaced the fixed 45px offset with a dynamic CSS variable |
|
@greptile review Addressed: Wired |
| `${rounded}px` | ||
| ); | ||
| // Re-align hash target when breadcrumbs render or resize | ||
| realignHashTarget(); |
There was a problem hiding this comment.
When the breadcrumb resizes after the user has manually scrolled away from the current hash target, setHeight calls scrollIntoView() because the hash remains in the URL. Viewport resizing, font loading, zooming, or breadcrumb wrapping can therefore jump the user back to an earlier target and lose their chosen scroll position. Limit realignment to initial hash navigation or otherwise avoid overriding later user scrolling.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/client/scroll-to-top.ts
Line: 138
Comment:
**Resize Restores Stale Target**
When the breadcrumb resizes after the user has manually scrolled away from the current hash target, `setHeight` calls `scrollIntoView()` because the hash remains in the URL. Viewport resizing, font loading, zooming, or breadcrumb wrapping can therefore jump the user back to an earlier target and lose their chosen scroll position. Limit realignment to initial hash navigation or otherwise avoid overriding later user scrolling.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…dcrumbs resizes (#121)
|
@greptile review Addressed: Added |
🧹 Preview Deployment CleanupThe preview deployment for this PR has been cleaned up. Preview URL was: Note: Cloudflare Pages deployments follow automatic retention policies. Old previews are cleaned up automatically. |
Summary
Fixes #121.
Problem
When clicking anchor links (TOC entries, headings, or footnotes) on documentation pages, the viewport scrolls past the heading text, obscuring it behind the sticky breadcrumbs bar (
.theme-doc-breadcrumbs). This happens because Docusaurus default.anchorscroll-margin only accounts for the navbar height (var(--ifm-navbar-height) + 0.5rem), ignoring the sticky breadcrumbs bar sitting below it (top: navbar + 2px, ~45px tall).Solution
Added
scroll-margin-topoffset for:is(.theme-doc-markdown, .markdown) :targetand.anchorinsrc/css/custom.csscalculating:calc(var(--ifm-navbar-height, 60px) + 2px + 45px + 0.75rem)var(--ifm-navbar-height, 60px) + 2px: navbar height plus offset matching sticky breadcrumbstop+ 45px: breadcrumb bar height+ 0.75rem: breathing room above the target elementScoped to doc content, covering headings via
.anchorand footnotes/targets via:target.Greptile Summary
Adds dynamic hash-link scroll offsets for documentation pages with sticky breadcrumbs.
ResizeObserverand exposes it through a CSS custom property.Confidence Score: 5/5
The PR appears safe to merge; both previous findings are fully addressed and no new actionable defect was established.
Dynamic breadcrumb measurement handles wrapped breadcrumbs, while the new one-shot guard prevents later resize events from overriding the user's manual scroll position.
Important Files Changed
Reviews (4): Last reviewed commit: "fix(client): avoid overriding user scrol..." | Re-trigger Greptile