fix: hard-code scroll margin per-page to account for fixed header size#1504
fix: hard-code scroll margin per-page to account for fixed header size#1504danielroe merged 4 commits intonpmx-dev:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughThis pull request introduces a scrolling offset feature to address anchor links being hidden behind sticky headers. The changes add a Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| name: 'docs', | ||
| path: '/package-docs/:path+', | ||
| alias: ['/package/docs/:path+', '/docs/:path+'], | ||
| scrollMargin: 180, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Check the actual file and verify line 10 content
cat -n app/pages/package-docs/[...path].vue | head -20Repository: npmx-dev/npmx.dev
Length of output: 781
🏁 Script executed:
# Check router.options.ts implementation
fd 'router.options.ts' --exec cat {} \;Repository: npmx-dev/npmx.dev
Length of output: 680
🏁 Script executed:
# Verify CSS values in the Vue component, specifically around lines 273-275
cat -n app/pages/package-docs/[...path].vue | sed -n '270,280p'Repository: npmx-dev/npmx.dev
Length of output: 379
🏁 Script executed:
# Search for scroll-related CSS or scroll-mt values in the file
rg 'scroll-m|scroll-margin' app/pages/package-docs/[...path].vueRepository: npmx-dev/npmx.dev
Length of output: 83
Align scrollMargin: 180 with CSS scroll-mt-32 (128 px) for consistent scroll positioning
Direct URL navigation with a hash anchor applies the CSS scroll-mt-32 rule (128 px), whereas router-driven navigation (e.g., clicking a TOC link) uses the scrollMargin: 180 offset. This 52 px difference results in inconsistent scroll positions depending on the navigation path, affecting user experience. Align both values to ensure the symbol lands at the same vertical position regardless of how the user reaches it.
…tead of a separate type file
|
Thanks for your first contribution, @WilcoSp! 👏 We'd love to welcome you to the npmx community. Come and say hi on Discord! And once you've joined, visit npmx.wamellow.com to claim the contributor role. |
When using table of content the scroll behaviour caused that the scrolled to element to be underneath the header(s). I've now added scroll margin to the scroll behaviour so that scrolled to element isn't any more underneath the header(s).
by default the margin is 70 but it's possible with
definePageMetato set a different scroll margin, at least right now the package, code & docs pages have different scroll margins due to their additional headers.before:
-> 
after:
-> 
this will fix #1428 & fix #1518