Make WordPress Core

Opened 6 weeks ago

Last modified 6 weeks ago

#66055 new enhancement

Editor: Migrate the Column block to the width block support

Reported by: aaronrobertshaw Owned by:
Priority: normal Milestone: 7.2
Component: Editor Version:
Severity: normal Keywords: gutenberg-merge has-patch has-unit-tests
Cc: Focuses: css

Description

Backport of Gutenberg PR ​https://github.com/WordPress/gutenberg/pull/76684.

Migrates the Column block from its ad-hoc width attribute to the standard
dimensions.width block support, so column widths can be set from global styles
and theme.json while existing columns keep working.

Columns sit in a flex container and size themselves with flex-basis rather than
width, so WP_Theme_JSON converts the computed width declaration and sets
flex-grow to 0. This covers the block level, block style variations, and
variation styles set within a responsive breakpoint.

The block.json and theme.json changes arrive with the next Gutenberg package
update, as they did for the Button block in #65388.

Change History (1)

This ticket was mentioned in ​PR #13411 on ​WordPress/wordpress-develop by ​@aaronrobertshaw.


6 weeks ago
#1

  • Keywords has-patch has-unit-tests added

Backport of Gutenberg PR ​https://github.com/WordPress/gutenberg/pull/76684

Trac ticket: https://core.trac.wordpress.org/ticket/66055

This migrates the Column block to the dimensions.width block support.

Columns are in a flex container and size themselves with flex-basis rather than width, so WP_Theme_JSON converts the generated width declaration and sets flex-grow: 0.

This PR backports:

  • flex-basis conversion for column widths in WP_Theme_JSON, covering the block level, block style variations, and variation styles set within a responsive breakpoint
  • accompanying WP_Theme_JSON tests.

The core/column block.json and theme.json changes arrive with the next Gutenberg package update, as they did for the Button block in #12046.

## Testing instructions

The core/column block.json and theme.json settings changes land with the next Gutenberg package update, so there is no width control in the editor yet.

This PR is the CSS generation, so test that directly.

  1. Add a column width to a theme's theme.json:
"styles": {
      "blocks": {
              "core/column": {
                      "dimensions": { "width": "25%" },
                      "@mobile": { "dimensions": { "width": "100%" } }
              }
      }
}
  1. Load a page with a Columns block and check the global styles. It should contain:
:root :where(.wp-block-column){flex-basis: 25%;flex-grow: 0;}
@media (width <= 480px){:root :where(.wp-block-column){flex-basis: 100%;flex-grow: 0;}}

Without the change these come out as width, which does not size a flex child, so the columns divide the space evenly instead of honouring the width.

## Use of AI

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: The mechanical port and test drafting; reviewed and edited by me.

Note: See TracTickets for help on using tickets.