A page with no headings gets `fullcontent`, so the floating sidebar moves between pages

オープン
#1,418 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
67/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
frontend

調査の方向性

Start by tracing how q2 decides whether to add fullcontent and render #quarto-margin-sidebar when the TOC is enabled but a page has no headings; compare that path with the toc: false case and the behavior described for Quarto 1. The repro provides a three-page website and expected body classes and sidebar counts. Reproduce with q2 render; done means page B keeps the floating layout and margin sidebar, while page C with toc: false still gets fullcontent.

索引モデルが issue の本文から書いたものです。

説明

This issue was drafted with Claude. The output shown comes from running each repro.

Bug description

When the TOC is on but a page has no headings, q2 leaves out the right margin sidebar
(#quarto-margin-sidebar) and adds fullcontent to <body>. The theme gives
body.floating.fullcontent a different grid from body.floating: it has no TOC columns and it
has fixed gutters. So on a site with a floating sidebar, the sidebar and the body column move
when you go from a page with headings to a page without headings. In our site, at a 1708px
window the sidebar moves 125px to the right. Between 992px and about 1200px the sidebar is also
wider (250px instead of 191px).

Quarto 1 does not do this. It keeps the empty margin sidebar on a page with no headings and does
not add fullcontent, so the layout stays the same from page to page. Quarto 1 adds
fullcontent only when the page sets toc: false, and q2 does the same in that case.

This could be the same logic as #1371: q2 adds fullcontent when it thinks nothing uses the
right margin. Here the trigger is an empty TOC, not .column-margin content.

Steps to reproduce
mkdir sidebar-shift && cd sidebar-shift
printf 'project:\n  type: website\nwebsite:\n  title: t\n  sidebar:\n    style: floating\n    contents: [a.qmd, b.qmd, c.qmd]\nformat:\n  html:\n    toc: true\n' > _quarto.yml
printf -- '---\ntitle: A\n---\n\n## One\n\ntext\n\n## Two\n\ntext\n' > a.qmd
printf -- '---\ntitle: B\n---\n\nNo headings here.\n' > b.qmd
printf -- '---\ntitle: C\ntoc: false\n---\n\n## One\n\ntext\n' > c.qmd
q2 render
for p in a b c; do
  echo "$p: $(grep -o '<body class="[^"]*"' _site/$p.html) margin-sidebar=$(grep -c 'id="quarto-margin-sidebar"' _site/$p.html)"
done

Open _site/a.html and _site/b.html in a browser wider than 992px and switch between them.
The sidebar moves.

Actual behavior

With q2 0.47.0 and with 0.45.0-nightly.20261112:

a: <body class="nav-sidebar floating quarto-light" margin-sidebar=1
b: <body class="nav-sidebar floating fullcontent quarto-light" margin-sidebar=0
c: <body class="nav-sidebar floating fullcontent quarto-light" margin-sidebar=0
Expected behavior

The same as Quarto 1.11.9, with the same files and quarto render:

a: <body class="nav-sidebar floating quarto-light" margin-sidebar=1
b: <body class="nav-sidebar floating quarto-light" margin-sidebar=1
c: <body class="nav-sidebar floating fullcontent quarto-light" margin-sidebar=0

Page b has no headings, but because toc is on it keeps the margin sidebar and the
body.floating grid. Only page c, which sets toc: false, gets fullcontent.

Workaround

We give body.nav-sidebar.floating.fullcontent .page-columns the theme's body.floating
grid-template-columns values, for min-width: 992px and for 768px–991.98px. This copies
the theme's grid values, so it can drift when the theme changes.

Environment
  • q2 0.47.0 (latest release) and 0.45.0-nightly.20261112, macOS arm64
  • Quarto 1.11.9 for the comparison
  • Same result with the posit-dev/product-doc-theme@q2 (posit-docs) extension, and with the
    plain website project type in the repro above
主要言語
Rust
スター
316
フォーク
23
平均マージ
11時間 49分
マージ済み PR(30日)
245

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quarto-dev/q2 のほかの issue

quarto-dev/q2 の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。