Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#50257 closed enhancement (fixed)

Editor: Remove default "layout" block attribute from WP_Block_Type::get_attributes

Reported by: aduth's profile aduth Owned by: gziolo's profile gziolo
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.0
Component: Editor Keywords: has-patch
Focuses: rest-api Cc:

Description

Background:

The implementation of WP_Block_Type::get_attributes will merge a default layout attribute to the registered attributes of a block type:

https://github.com/WordPress/wordpress-develop/blob/adcf5cf7/src/wp-includes/class-wp-block-type.php#L193-L215

The layout attribute was relevant for a short time in earlier iterations of the block editor, specifically in initial implementations of Columns block for Gutenberg, where individual Column blocks would use the layout attribute to assign their position within columns styled using CSS Grid Layout.

https://github.com/WordPress/gutenberg/pull/3745

It was later effectively deprecated in favor of an implementation which used individual wrapper elements for each column.

https://github.com/WordPress/gutenberg/pull/7234
https://github.com/WordPress/gutenberg/pull/11029

The fact that a reference had continued to exist in WP_Block_Type::get_attributes is likely to have been an oversight. It did exist at the time of (and after) the changes of GB#11029

https://github.com/WordPress/gutenberg/blob/45cb5178/lib/class-wp-block-type.php

Proposal:

The merging behavior which assigns the layout attribute should be removed.

Impact:

It's unclear (but unlikely) that this attribute will have provided any usefulness for block implementations, since there is no attached functionality aside from the block type attribute schema definition.

At the current point in time, there is only a single reference to WP_Block_Type::get_attributes in the current core codebase: in the block server render endpoint, which would not be impacted by its removal:

https://github.com/WordPress/wordpress-develop/blob/8efc532/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php#L65

With the pending introduction of a block types endpoint (#47620), it's more likely that if the behavior isn't changed, it could become a source of confusion for consumers of this endpoint.

Attachments (1)

50257.diff (600 bytes) - added by aduth 3 years ago.

Download all attachments as: .zip

Change History (4)

@aduth
3 years ago

#1 @aduth
3 years ago

  • Keywords has-patch added

#2 @TimothyBlynJacobs
3 years ago

  • Focuses rest-api added
  • Milestone changed from Awaiting Review to 5.5
  • Version set to 5.0

I don't see any issue with this from the REST API side of things.

#3 @gziolo
3 years ago

  • Owner set to gziolo
  • Resolution set to fixed
  • Status changed from new to closed

In 48118:

Editor: Remove default "layout" block attribute from WP_Block_Type::get_attributes

The merging behavior which assigns the layout attribute in WP_Block_Type gets removed.

Props aduth, TimothyBlynJacobs.
Fixes #50257.

Note: See TracTickets for help on using tickets.