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

Open
#5,461 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
64/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php, wordpress
Domain
frontend

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
PHP
Stars
28
Forks
5
Avg merge
2h 59m
Merged PRs (30d)
942

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/blocks-engine

All issues in Automattic/blocks-engine

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.