Website content moves down after the first paint when the header is taller than the default offset

Ouverte
#15,405 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
57/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
css, javascript
Domaine
frontend

Piste de recherche

Start with the named rules in src/resources/projects/website/navigation/quarto-nav.scss and the initialization code in src/resources/projects/website/navigation/quarto-nav.js; compare when the content offset and announcement visibility are set against the first paint. Reproduce with the provided website configuration and inspect layout shifts in Chrome’s Performance panel. Done means #quarto-content stays at the same position when the announcement appears or a taller navbar is used.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug website-navigation websites
I have:
  • searched the issue tracker for similar issues
  • installed the latest version of Quarto CLI
  • formatted my issue following the Bug Reports guide
Bug description

On a website with a fixed navbar, the content moves down a short time after each page loads.

The body gets a fixed top padding from CSS, sized for a one-row navbar.
The real padding, from the height of the header, comes from quarto-nav.js on DOMContentLoaded.
The announcement bar also stays hidden until DOMContentLoaded.
The browser paints the page before that event.
So when the header is taller than the CSS value, the content jumps once the script runs.
An announcement, a navbar that wraps on a small screen, or a theme with a taller navbar all trigger it.

The CSS offset came with the fix for #491, before the announcement bar existed (#7517), so the bar is not part of it.
A small inline script right after the header could set the offset and show the bar before the content is parsed.

Related: #491, #7517.

Steps to reproduce

_quarto.yml:

project:
  type: website
website:
  title: Plain
  navbar:
    left:
      - href: index.qmd
        text: Home
      - href: about.qmd
        text: About
  announcement:
    content: "A note for readers."

index.qmd and about.qmd each hold a title and one line of text.
Render the site, open _site/about.html in Chrome, and record the layout shifts (DevTools, Performance panel).

Actual behavior

#quarto-content is first painted at y = 64px, then moves to y = 101px when the announcement appears and the padding is updated.

The recording below loads Home, About, then Home again.
On each load the page is painted without the bar, then the bar appears and the content drops.
The server pauses 1.5 seconds in the middle of each page to make the jump easy to see.
On a fast connection the same jump happens within about 100 ms.

https://github.com/user-attachments/assets/302ab057-7759-4626-a4cd-3dc71efd25ba

Expected behavior

#quarto-content stays where it is first painted.

Your environment
  • Quarto 99.9.9 (built from cda41021442b20964e10e265b9dcdf81f490c18e).
  • macOS 27.2, Chromium-based browser (Brave).
Quarto check output
Quarto 99.9.9
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.13.0: OK
      Dart Sass version 1.107.1: OK
      Deno version 2.9.8: OK
      Typst version 0.15.1: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 99.9.9
      commit: cda41021442b20964e10e265b9dcdf81f490c18e
Langage dominant
JavaScript
Étoiles
6.2k
Forks
492
Merge moyen
15 h 15 min
PR mergées (30 j)
94

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de quarto-dev/quarto-cli

Toutes les issues de quarto-dev/quarto-cli

Issues similaires

Plus d'issues JavaScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.