Merged nav+ul core/navigation root takes the list's width:100% over the source nav's width

Đang mở
#5,461 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
64/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ệ
php, wordpress
Lĩnh vực
frontend

Hướng nghiên cứu

Start by locating the transformer that merges the source cnave and cule into a ccore/navigatione root, then find the existing transformer tests. Reproduce the reduced page and inspect how its nav and list width rules are projected onto the merged root. Done means a test shows a 424px root beside the logo and item widths matching the source within 1px.

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

Mô tả

Finding

When a source <nav> and its <ul> merge into one core/navigation root, the list's author classes are copied onto that root. A list rule such as .menu{width:100%} then competes with the source nav's own nav{width:424px} on the same element, and wins on specificity. The navigation fills its whole flex parent, wraps below the logo, and every flex:1 1 auto item stretches.

This came from a Wix site import: the desktop header grew from 77px to 149px in the reduced case, and from 131px to 255px on the real site (with #5422).

Reduced page

<!doctype html><html><head><meta charset="utf-8"><title>index</title><style>
body{margin:0;font:15px sans-serif;background:#f4f3ef}
header{display:flex;align-items:center;gap:40px;padding:20px 280px}
.logo{font-size:28px;color:#555}
nav{display:flex;width:424px}
.menu{display:flex;flex-wrap:wrap;gap:6px;margin:0;padding:0;list-style:none;width:100%}
.item{flex:1 1 auto}
.link{flex:1;display:block;text-decoration:none;color:#333;padding:10px 8px;text-align:center}
.link.current{background:#e0dfdb}
</style></head><body>
<header><div class="logo">travelism</div><nav aria-label="Site"><ul class="menu">
<li class="item"><div><a class="link current" href="index.html">Home</a></div></li>
<li class="item"><div><a class="link" href="a.html">About</a></div></li>
<li class="item"><div><a class="link" href="b.html">Reiseziele</a></div></li>
<li class="item"><div><a class="link" href="c.html">Wanderful</a></div></li>
</ul></nav></header>
<main><p>Page text.</p></main>
</body></html>
source imported (SSI 1.33.512 / BE 0.45.448)
nav width 424 (nav) 880 (nav.wp-block-navigation.menu)
nav top 20 (beside logo) 92 (wrapped below logo)
"Home" item 87×37 201×37
header height 77 149

Width rules that match the generated <nav class="wp-block-navigation … blocks-engine-list-navigation menu">:

:where(.blocks-engine-source-nav-…-0):not(be-t-0) { width:424px }   /* source nav, specificity 0,0,1 */
.menu { width:100% }                                                 /* source ul, specificity 0,1,0, now on the same element */

Expected

The merged root renders at the source nav's width (424px here), and the items match their source widths. A list rule should only win where it also won in the source. One way to get there: project the list's box declarations onto the root only where the source nav did not size that axis. Another: give the merged root the list's rule under a selector that cannot outrank the nav's projection.

Related: #4945 (the responsive root inheriting the list's classes; closed) and #1482.

Acceptance

  • In the reduced page, the core/navigation root is 424px wide and sits beside the logo, and each item width matches its source width ±1px.
  • A test covers the transformer output for the reduced page.

AI disclosure: found and reduced by Claude (Pi via Roadie) during a Data Liberation import loop on a Wix site; reviewed by @chubes4.

Ngôn ngữ chính
PHP
Star
28
Fork
5
Merge trung bình
2 giờ 59 phút
Pull request đã merge (30 ngày)
942

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 Automattic/blocks-engine

Tất cả issue của Automattic/blocks-engine

Issue tương tự

Thêm issue về PHP

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.