Skip to content

DOC-6348 fixed (hopefully) bad scrolling in pages with Mermaid diagrams#2868

Merged
andy-stark-redis merged 1 commit intomainfrom
DOC-6348-dodgy-scrolling
Mar 12, 2026
Merged

DOC-6348 fixed (hopefully) bad scrolling in pages with Mermaid diagrams#2868
andy-stark-redis merged 1 commit intomainfrom
DOC-6348-dodgy-scrolling

Conversation

@andy-stark-redis
Copy link
Contributor

@andy-stark-redis andy-stark-redis commented Mar 9, 2026

Augie seems to have fixed the issue where an anchor link jumps slightly off-position when the target page has Mermaid diagrams in it. I've tried a few other pages but I can't swear that this doesn't introduce some other fault, so I'd be happy to hear any feedback about this.

Example: the link in this section to the other Pattern 1: Fail fast section in the target page should now jump to the heading correctly - previously, it didn't.


Note

Medium Risk
Adjusts global heading anchor offsets and adds load-time hash re-scrolling, which can change navigation behavior site-wide and may introduce unexpected scroll positioning on some pages.

Overview
Improves in-page anchor navigation in docs pages that render dynamic content (e.g., Mermaid) by increasing header scroll-margin-top (scroll-mt-6scroll-mt-24) so targets land below the sticky header.

Adds a window.load handler that, when a hash is present, re-scrolls to the target element multiple times (after short delays) using an explicit offset based on header.sticky height, including support for hashes that include query parameters.

Written by Cursor Bugbot for commit 16cabe2. This will update automatically on new commits. Configure here.

@andy-stark-redis andy-stark-redis requested review from a team and dwdougherty March 9, 2026 16:20
@andy-stark-redis andy-stark-redis self-assigned this Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

DOC-6348

@jit-ci
Copy link

jit-ci bot commented Mar 9, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.


const header = document.querySelector('header.sticky')
const headerHeight = header ? header.offsetHeight : 0
const offset = headerHeight + 16 // small extra padding
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSS scroll-margin and JS offset calculation mismatch

Medium Severity

The CSS scroll-mt-24 sets a scroll margin of 6rem (96px), but the JS offset calculation uses headerHeight + 16 which equals ~86px (the header is h-[70px]). On every page load with a hash, the browser first scrolls natively using the 96px CSS margin, then the JS overrides to 86px at 50ms/250ms/500ms intervals, causing a visible 10px jump. The hardcoded + 16 padding doesn't account for the CSS scroll-margin value it's competing with.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Collaborator

@dwdougherty dwdougherty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked all the pages with Mermaid diagrams and also a bunch of other random pages and I didn't notice anything untoward. Other folks should also do some testing, so I'm just leaving this review as a comment.

@andy-stark-redis
Copy link
Contributor Author

Thanks for checking @dwdougherty :-)

@dwdougherty dwdougherty requested a review from a team March 10, 2026 17:18
@rrelledge
Copy link
Collaborator

I did a little bit of testing, and it looks like this change may have affected the "On this page" links. If you click those to navigate, it seems to add extra space compared to latest. I don't think it's a huge problem, but I thought I'd mention it just in case.

Examples:
After change: https://redis.io/docs/staging/DOC-6348-dodgy-scrolling/operate/rs/databases/create
Before change: https://redis.io/docs/latest/operate/rs/databases/create/

@andy-stark-redis
Copy link
Contributor Author

@rrelledge Thanks very much for checking :-) Do you think users will be disoriented if the heading isn't at the top when they follow an "On this page" link? The gap doesn't seem to be proportional to the page length (eg, I tried the last in-page link on the very long Streams page and it still scrolled to within a couple of lines of the ideal position), so hopefully this isn't something that's going to trip us up on specific pages.

@rrelledge
Copy link
Collaborator

@andy-stark-redis I don't think the slight gap should be too confusing, so I'm okay with it if everyone else is.

Copy link
Collaborator

@dwdougherty dwdougherty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go ahead and approve. Other folks can still take a look if they want to.

@dwdougherty dwdougherty requested a review from a team March 11, 2026 21:16
@andy-stark-redis
Copy link
Contributor Author

@dwdougherty @rrelledge Thanks for your input - I'll merge it and I guess I can always fix it up later if something unexpected happens :-)

@andy-stark-redis andy-stark-redis merged commit 8006b7d into main Mar 12, 2026
47 checks passed
@andy-stark-redis andy-stark-redis deleted the DOC-6348-dodgy-scrolling branch March 12, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants