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: |
|
Owned by: |
|
---|---|---|---|
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:
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:
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.
I don't see any issue with this from the REST API side of things.