Respect flex-direction:column when converting flex containers#338
Merged
Conversation
A flex container with `flex-direction: column` / `column-reverse` is a vertical stack, but the HTML transformer converted any `display:flex` container with multiple children to a horizontal `core/columns` block. Hero stacks (eyebrow, title, subhead, buttons) rendered side-by-side instead of stacked — the corpus-diagnostics `layout_direction_misrecognition :: columns_from_vertical_flex` cluster. Key off the CSS `flex-direction` value, never fixture names or classes: - ColumnsPattern::looksLikeColumnsContainer now declines a container whose resolved style declares `display:flex` with a column main axis, so the host transformer routes it to the generic vertical `core/group` path. Row / row-reverse / default flex and grid layouts are untouched, so legitimate horizontal columns are preserved. - layoutAttribute emits an explicit `orientation: vertical` for column-flex containers. A `core/group` flex layout otherwise defaults to a horizontal Row, so without this the children would still render side-by-side. Adds parity fixtures for both directions (vertical flex -> vertical core/group; horizontal flex -> core/columns), updates the corpus-detector unit test to assert the live transformer now stacks vertically, and drives the columns_from_vertical_flex cluster from 21 to 0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A vertical flex container (
display:flex; flex-direction:column— e.g. a hero with eyebrow → title → subhead → buttons stacked vertically) was converted to a horizontalcore/columnsblock. The page rendered a broken side-by-side row instead of a vertical stack. The corpus-diagnostics harness (#337) detects this aslayout_direction_misrecognition :: columns_from_vertical_flex.The transformer recognized any
display:flexcontainer with multiple children ascore/columnswithout ever inspectingflex-direction.Fix (generic, keys off the CSS
flex-directionvalue — never fixture names/classes)1.
ColumnsPattern::looksLikeColumnsContainer— declines a container whose resolved inline style declaresdisplay:flex(orinline-flex) andflex-direction: column/column-reverse. The host transformer then routes the element down the existing generic path, emitting acore/groupthat preserves the container's classes/styles. Row /row-reverse/ default flex and grid layouts are untouched, so legitimate horizontal column layouts keep their current behavior.2.
StyleResolutionTrait::layoutAttribute— emits an explicitorientation: verticalfor column-flex containers. Acore/groupflex layout otherwise defaults to a horizontal Row in WordPress, so without this the children would still render side-by-side. Horizontal flex stays{ "type": "flex" }(implicit horizontal).Before / after
Input:
<div class="hero" style="display:flex;flex-direction:column;gap:1rem">…</div>core/columns→core/columnchildren laid out horizontally (broken side-by-side row).core/groupwithlayout: { "type": "flex", "orientation": "vertical" }→ children stack vertically.Horizontal flex (
display:flex, row/default) still converts tocore/columns— unchanged.Tests
composer test:canonical+composer paritygreen before changes.html-vertical-flex-column-becomes-group(vertical flex → verticalcore/group, asserts nowp:columns) andhtml-horizontal-flex-stays-columns(row flex →core/columns).tests/unit/corpus-detectors.php: detector logic now exercised with a stubbed verifier, plus a live-transformer regression guard (case 4e/4f) asserting vertical flex emits a verticalcore/groupand horizontal flex stayscore/columns.composer testgreen: contracts, unit (CorpusDetectors 27 passed), parity 175 fixtures, packaging proof.php -lclean on all changed files.Harness cluster delta (
composer corpus-diagnostics)layout_direction_misrecognition :: columns_from_vertical_flexNo other cluster regressed.
AI assistance