[GH-ISSUE #4658] Docs site anchor links not working properly #18644

Closed
opened 2026-04-15 17:12:21 -05:00 by GiteaMirror · 7 comments
Owner

Originally created by @erquhart on GitHub (Sep 14, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4658

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Navigate to an anchored link, eg., https://www.better-auth.com/docs/plugins/organization#listing-roles

Current vs. Expected behavior

The page should scroll to Dynamic Access Control > Listing Roles, instead it scrolls part of the way down. Where it lands is different every time. Some anchors trigger almost no scroll at all.

What version of Better Auth are you using?

n/a

System info

n/a

Which area(s) are affected? (Select all that apply)

Documentation

Auth config (if applicable)


Additional context

I share a lot of Better Auth docs links with folks, this makes it tough for people to find things.

Originally created by @erquhart on GitHub (Sep 14, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4658 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Navigate to an anchored link, eg., https://www.better-auth.com/docs/plugins/organization#listing-roles ### Current vs. Expected behavior The page should scroll to Dynamic Access Control > Listing Roles, instead it scrolls part of the way down. Where it lands is different every time. Some anchors trigger almost no scroll at all. ### What version of Better Auth are you using? n/a ### System info ```bash n/a ``` ### Which area(s) are affected? (Select all that apply) Documentation ### Auth config (if applicable) ```typescript ``` ### Additional context I share a lot of Better Auth docs links with folks, this makes it tough for people to find things.
GiteaMirror added the locked label 2026-04-15 17:12:21 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 14, 2025):

This anchor link scrolling issue was caused by sticky headers and navigation elements covering the anchor targets. A recent fix was merged that adds a CSS scroll-padding-top to the html element, calculated from the heights of the sticky nav, banner, and table of contents, plus extra padding. This ensures anchors scroll fully into view and aren't hidden under UI elements. The fix is live as of the v1.3.8 release, so if you're still seeing the problem, try a hard refresh or clear your cache to make sure you're seeing the latest version of the docs site. If the issue persists, let us know the specific URL and browser so we can investigate further.
See PR #4169 for details

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3289905211 --> @dosubot[bot] commented on GitHub (Sep 14, 2025): <!-- Answer --> This anchor link scrolling issue was caused by sticky headers and navigation elements covering the anchor targets. A recent fix was merged that adds a CSS scroll-padding-top to the html element, calculated from the heights of the sticky nav, banner, and table of contents, plus extra padding. This ensures anchors scroll fully into view and aren't hidden under UI elements. The fix is live as of the v1.3.8 release, so if you're still seeing the problem, try a hard refresh or clear your cache to make sure you're seeing the latest version of the docs site. If the issue persists, let us know the specific URL and browser so we can investigate further. [See PR #4169 for details](https://github.com/better-auth/better-auth/pull/4169) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/4017312b-a04a-4e49-86f9-e5dff6c21542?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/4017312b-a04a-4e49-86f9-e5dff6c21542?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/4017312b-a04a-4e49-86f9-e5dff6c21542?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/4017312b-a04a-4e49-86f9-e5dff6c21542?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/4017312b-a04a-4e49-86f9-e5dff6c21542?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/4017312b-a04a-4e49-86f9-e5dff6c21542?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/4017312b-a04a-4e49-86f9-e5dff6c21542?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4658)
Author
Owner

@erquhart commented on GitHub (Sep 14, 2025):

@dosubot I see that fix, but the link in my OP and most other anchors on various pages have this issue currently in production.

<!-- gh-comment-id:3289910225 --> @erquhart commented on GitHub (Sep 14, 2025): @dosubot I see that fix, but the link in my OP and most other anchors on various pages have this issue currently in production.
Author
Owner

@erquhart commented on GitHub (Sep 14, 2025):

Playing with it a bit more, it seems like the pages linked in the top section of the sidebar, like Basic Usage, all work fine. But pages in the other sections don't scroll correctly on load. Just observing visually, it seems like scroll starts, but then the sidebar section starts expanding and stops the initial scroll.

Here's another example, should scroll to the bottom of the page: https://www.better-auth.com/docs/integrations/next#for-nextjs-release-1520-and-above

<!-- gh-comment-id:3289912789 --> @erquhart commented on GitHub (Sep 14, 2025): Playing with it a bit more, it seems like the pages linked in the top section of the sidebar, like Basic Usage, all work fine. But pages in the other sections don't scroll correctly on load. Just observing visually, it seems like scroll starts, but then the sidebar section starts expanding and stops the initial scroll. Here's another example, should scroll to the bottom of the page: https://www.better-auth.com/docs/integrations/next#for-nextjs-release-1520-and-above
Author
Owner

@dosubot[bot] commented on GitHub (Sep 14, 2025):

You're right—while the CSS fix for anchor scrolling is live, it only works when the heights of sticky elements (like the nav, banner, and TOC) are set as CSS variables on the root element. In practice, only the nav height is set globally; the others are set conditionally and often aren't reflected at the root level. This means the scroll offset can be wrong when banners or the TOC are present, so anchors land inconsistently or get covered by sticky UI. There’s currently no JS measuring or updating these offsets dynamically, which explains why the issue persists on many pages.

As a workaround, you can manually scroll or use browser search to find the section after following an anchor. For a robust fix, the site would need to dynamically update the scroll offset based on the actual layout at the time of navigation.

If you can share your browser and device details, I can help rule out any client-specific issues, but this looks like a limitation of the current implementation.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3289913012 --> @dosubot[bot] commented on GitHub (Sep 14, 2025): <!-- Answer --> You're right—while the CSS fix for anchor scrolling is live, it only works when the heights of sticky elements (like the nav, banner, and TOC) are set as CSS variables on the root element. In practice, only the nav height is set globally; the others are set conditionally and often aren't reflected at the root level. This means the scroll offset can be wrong when banners or the TOC are present, so anchors land inconsistently or get covered by sticky UI. There’s currently no JS measuring or updating these offsets dynamically, which explains why the issue persists on many pages. As a workaround, you can manually scroll or use browser search to find the section after following an anchor. For a robust fix, the site would need to dynamically update the scroll offset based on the actual layout at the time of navigation. If you can share your browser and device details, I can help rule out any client-specific issues, but this looks like a limitation of the current implementation. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/07886216-9e21-4a00-992f-d27fc96a01e5?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/07886216-9e21-4a00-992f-d27fc96a01e5?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/07886216-9e21-4a00-992f-d27fc96a01e5?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/07886216-9e21-4a00-992f-d27fc96a01e5?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/07886216-9e21-4a00-992f-d27fc96a01e5?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/07886216-9e21-4a00-992f-d27fc96a01e5?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/07886216-9e21-4a00-992f-d27fc96a01e5?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4658)
Author
Owner

@erquhart commented on GitHub (Sep 14, 2025):

I suspect the reason Fumadocs own site doesn't have this issue is that it doesn't animate scroll - maybe disabling that is the quick fix until animated scroll can be supported for anchors across the site: https://fumadocs.dev/docs/ui/markdown/twoslash#cache

<!-- gh-comment-id:3289913680 --> @erquhart commented on GitHub (Sep 14, 2025): I suspect the reason Fumadocs own site doesn't have this issue is that it doesn't animate scroll - maybe disabling that is the quick fix until animated scroll can be supported for anchors across the site: https://fumadocs.dev/docs/ui/markdown/twoslash#cache
Author
Owner

@Kinfe123 commented on GitHub (Sep 15, 2025):

Yeah i have noticed this issue a bit ago and it should be fixed.

<!-- gh-comment-id:3291772757 --> @Kinfe123 commented on GitHub (Sep 15, 2025): Yeah i have noticed this issue a bit ago and it should be fixed.
Author
Owner

@erquhart commented on GitHub (Sep 20, 2025):

Still happening: https://www.better-auth.com/docs/integrations/next#for-nextjs-release-1520-and-above

<!-- gh-comment-id:3315114082 --> @erquhart commented on GitHub (Sep 20, 2025): Still happening: https://www.better-auth.com/docs/integrations/next#for-nextjs-release-1520-and-above
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18644