Blocks: Add new attribute types; use for block bindings#73624
Blocks: Add new attribute types; use for block bindings#73624
Conversation
|
Size Change: +1.22 kB (+0.05%) Total Size: 2.57 MB
ℹ️ View Unchanged
|
1cb13a4 to
61cb516
Compare
|
Flaky tests detected in 61cb516. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20024764290
|
|
Unit tests are currently failing due to a built-in check in Core's diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
index d33a52ef51..841848cf56 100644
--- a/src/wp-includes/rest-api.php
+++ b/src/wp-includes/rest-api.php
@@ -2193,7 +2193,7 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) {
}
}
- $allowed_types = array( 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null' );
+ $allowed_types = array( 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null', 'datetime', 'url' );
if ( ! isset( $args['type'] ) ) {
/* translators: %s: Parameter. */However, that would mean that Core would no longer follow JSON Schema. To me, this doesn’t seem like a good idea, especially since newer versions of JSON Schema offer support for formats (in the "Validation" part of the standard). |
|
Why is the current "rich-text" type not breaking these unit tests? The block attributes are already not JSON Schema compatible. |
That's a good question. I haven't been able to locate any code dedicated to handling that type yet. My hypothesis is that
Solely because of the |
|
I think we probably have a lot more inconsistencies. Some things that come to mind:
|
What?
datetimeandurl.core/post-datablock bindings source, in order to only display fields that match a given attribute type.Fixes #72446. Reverts #72712.
An alternative approach was discussed in #72716.
Why?
To remove incompatible source items from the block bindings UI for a given block bindings source.
For example, when we show the available items from the
core/post-datalist for the Date block'sdatetimeattribute, we only want to show thedateandmodifiedsource items, but notlink(which is anurland thus incompatible with adatetimefield).How
By extending the list of allowed block attribute types, and changing some block attribute types to those newly added types.
Testing Instructions
datetimeattribute to expand the dropdown menu. It should contain the "Post Data" source.Screenshots or screencast