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

Đang mở
#1,418 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
67/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Rust
Star
316
Fork
23
Merge trung bình
11 giờ 49 phút
Pull request đã merge (30 ngày)
245

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của quarto-dev/q2

Tất cả issue của quarto-dev/q2

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.