Shared header splits when page-only CSS sets a no-op margin:0 on the header for most routes

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

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
32/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
css, html, php
領域
build-system

調査の方向性

Start from the code that folds page-level CSS declarations into template_parts shell identity — the path the closed #3432 fix touched — and build a 4-route fixture matching the reproduction above. The fix needs to compare the page-only declaration's computed value against what the element already gets by default (<header> has margin 0) before letting it split the part. Done looks like a test where all four routes share one header, while a genuinely non-equivalent page rule still yields its own variant.

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

説明

Summary

One route in a shared header group can be split into its own header variant because of page CSS that changes nothing visually. If 3 of 4 routes' page CSS sets margin:0 on the header, the one route without that rule gets header-<hash> and its own page-<slug> template. A <header> already has a zero margin by default, so both versions render identically.

Related to #3432 (closed), which kept one extra page stylesheet from splitting the part. This is the reverse: the majority of routes carry a page-only rule and the minority lacks it.

Reproduction (4 routes: /, /services/, /services/a/, /services/b/)

Shared assets/site.css: .menu{display:flex;list-style:none}

Header on every route (only aria-current moves):

<header id="site-header"><nav><ul class="menu"><li><a href="/about/">About</a></li><li><a href="/services/">Services</a><ul><li><a href="/services/a/" aria-current="page">Service A</a></li><li><a href="/services/b/">Service B</a></li></ul></li></ul></nav></header>

Every route except /services/ also has this in its own <head>:

<style>#site-header{margin:0}</style>

Observed

  • template_parts: header, header-b889b7e71e3f, footer; page-services uses header-b889b7e71e3f.
  • margin-top:0px;margin-bottom:0px (the longhands Wix emits) splits the same way.
  • Without the page rule, or with it on all 4 routes, one header is shared.
  • On real routes, the split also changes lowering on the excluded page: its menu stays as plain core/group items carrying runtime data-selected and selected-state styles, while the shared part gets core/navigation.

Expected

One shared header on all 4 routes. A page-only declaration on the shared source element whose computed value equals the value without it (here margin:0 on <header>, whose UA margin is 0, inside a group whose block margins Blocks Engine already zeroes) should not affect shell identity. A non-equivalent page rule should still split the part, or be scoped to its page as in #3432.

Real-site context

Wix code-splits per-page CSS. On a 4-route Wix import, the header's :is(#comp-…) rule includes margin-top/bottom/left/right:0px on 3 routes and leaves it out on the entry route. Removing those longhands, or adding them to the entry route, makes all 4 routes share the header (the selected-state fixes #7368 and #7386 cover the remaining route-current differences).

AI disclosure: reduced and filed by Claude (Claude Code via Franklin/Roadie) from a real-site import investigation.

主要言語
PHP
スター
29
フォーク
6
平均マージ
3時間 40分
マージ済み PR(30日)
813

環境構築

はじめの一歩

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

Automattic/blocks-engine のほかの issue

Automattic/blocks-engine の issue をすべて見る

似ている issue

PHP の issue をもっと見る

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

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