Skip to content

fix: keep fixed navbar pinned within its height - #15397

Open
mcanouil wants to merge 1 commit into
quarto-dev:mainfrom
mcanouil:fix/navbar-scroll-gap
Open

mcanouil wants to merge 1 commit into
quarto-dev:mainfrom
mcanouil:fix/navbar-scroll-gap

Conversation

@mcanouil

@mcanouil mcanouil commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Description

On a website with a fixed navbar, the header hides as soon as the page scrolls about 5 px.
The body keeps a top padding as tall as the header, so an empty band shows at the top of the page until the scroll passes that padding.
A taller header makes the band bigger, for example with a secondary navigation row.

Headroom is created without an offset, so it unpins the header right away.
This passes the header height as the offset, and updateDocumentOffset() keeps it in step when the header height changes, from the same ResizeObserver that already updates the body padding.
The header now stays in place until the page has scrolled past its height, then hides as before.
Scrolling up still brings it back.

The new Playwright test checks that the header stays pinned at half its height, hides further down, and comes back on scroll up.

Both clips use a website with a fixed navbar and a docked sidebar.
The sidebar has a border only to make the layout easier to see.
They scroll slowly from the top, then further down the page, back up a little, and down again.
Before, with stock Quarto, the header hides at once: the sidebar moves up to the top of the window, but the page content keeps an empty band above the title.
Further down, it hides and comes back as usual.

navbar-scroll-before.mp4

After this change, the header and the sidebar stay in place until the scroll passes the 61 px header height, then the header hides with no gap.
Further down, it hides on scroll down and comes back on scroll up, as before.

navbar-scroll-after.mp4

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR

The fixed navbar hid after about 5 px of scroll, while the body kept
a top padding as tall as the header. An empty band then showed at the
top of the page until it scrolled past that padding.

Headroom now gets the header height as its offset, and the offset
follows the header height when it changes.
@mcanouil mcanouil added the bug Something isn't working label Nov 18, 2026
@mcanouil mcanouil self-assigned this Nov 18, 2026
@posit-snyk-bot

posit-snyk-bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@mcanouil mcanouil removed the bug Something isn't working label Nov 18, 2026
@mcanouil
mcanouil marked this pull request as ready for review November 18, 2026 20:42
@mcanouil mcanouil assigned mcanouil and unassigned mcanouil Nov 20, 2026
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.

2 participants