-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REST API: Update default values for fields in the block type schema #22695
Conversation
Size Change: 0 B Total Size: 1.12 MB ℹ️ View Unchanged
|
I will test this later today. |
As discussed in private chat, another option is to tweak the actual usage of this field in the inserter to treat an empty array as no parents and bail out from the check. |
By "no parents", do you mean "no restriction on the types of parents" or "not allowed to be inserted within any nested context"? I think it could be a worthwhile distinction with each having valid use-cases, where it could be represented by the difference between |
Exactly, this is something I'm hesitant about. There is also an |
Related: #7845 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This didn't work in my testing.
These lines need to change
The null value means you can't use isset. |
01de805
to
5fcaf3f
Compare
I went through the list of changes applied in WordPress core and tried to align this PR accordingly:
It turned out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is line nit pick and this can be merged - https://github.com/WordPress/gutenberg/pull/22695/files#r433239396
d22ee26
to
0f5ab25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
This change aligns with the state of the corresponding change proposed to WordPress core to
WP_Block_Type
class: https://core.trac.wordpress.org/ticket/48529.More details about this optional field:
https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#parent-optional
Related code that uses this field that confirms that using an empty array would lead to unexpected results:
gutenberg/packages/block-editor/src/store/selectors.js
Lines 1168 to 1173 in 1530b55
gutenberg/packages/block-editor/src/store/selectors.js
Lines 1122 to 1136 in 1530b55