-
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
Interactivity API: Add block supports
for clientNavigation
and interactive
properties on block.json
schema.
#58132
Conversation
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/compat/wordpress-6.5/interactivity-api/interactivity-api.php ❔ phpunit/blocks/render-query-test.php |
944cd9f
to
d2570a8
Compare
Flaky tests detected in d2570a8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7630045565
|
d2570a8
to
1269359
Compare
$is_interactive_bool = isset( $block_object->supports['interactivity'] ) && true === $block_object->supports['interactivity']; | ||
$is_interactive_object = isset( $block_object->supports['interactivity']['interactive'] ) && true === $block_object->supports['interactivity']['interactive']; | ||
$client_navigation = isset( $block_object->supports['interactivity']['clientNavigation'] ) && true === $block_object->supports['interactivity']['clientNavigation']; |
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 PHP 5.6 compatible.
This change would not work in < 7.0 :
$is_interactive_bool = (bool) ( $block_object->supports['interactivity'] ?? false );
$is_interactive_object = (bool) ( $block_object->supports['interactivity']['interactive'] ?? false );
$client_navigation = (bool) ( $block_object->supports['interactivity']['clientNavigation'] ?? false );
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.
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.
I haven't checked the code of the Query block yet, so this is just preliminary.
packages/block-library/src/form-submission-notification/block.json
Outdated
Show resolved
Hide resolved
schemas/json/block.json
Outdated
"properties": { | ||
"clientNavigation": { | ||
"type": "boolean", | ||
"description": "Indicates if a block is compatible with Interactivity API client side navigation.\n\nSet as false if the block is using vanilla JS or another framework to handle interactions.", |
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.
"description": "Indicates if a block is compatible with Interactivity API client side navigation.\n\nSet as false if the block is using vanilla JS or another framework to handle interactions.", | |
"description": "Indicates whether a block is compatible with the Interactivity API client-side navigation.\n\nSet it to true only if the block is not interactive or if it is interactive using the Interactivity API. Set it to false if the block is interactive but uses vanilla JS, jQuery or another JS framework/library other than the Interactivity API.", |
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.
We could get help from a native speaker here. This is complex to understand 🙂
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.
Ping @sirreal, @ndiego or @ryanwelcher
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.
Tricky 🙂 I've read the descriptions and have questions:
interactivity
: boolean|object - What does true
mean here? Enable all the features?
true === { clientNavigation: true, interactive: true }
(omission) === false === {}
Should we include the default value for interactivity
(which I think is false
)?
Can we have clientNavigation
without interactive
, or does clientNavigation
require interactive
(if they're dependent we can reflect that in the schema itself instead of describing it).
What does "interactive" mean here?
Set it to true only if the block is not interactive or if it is interactive using the Interactivity API
Set it to false if the block is interactive but uses vanilla JS… other than the Interactivity API
Interactive sounds like interactivity.interactive
, but are we talking about that? Or more generally that a block has client-side JavaScript to make it do things.
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.
interactivity: boolean|object - What does true mean here? Enable all the features?
Yes
(omission) === false === {}
I think in this case would be:
{
clientNavigation: false,
interactive: false
}
Should we include the default value for interactivity (which I think is false)?
Sure, done.
Interactive sounds like interactivity.interactive, but are we talking about that? Or more generally that a block has client-side JavaScript to make it do things.
Interactive means that a block is using the Interactivity API as alternative of JavaScript made things.
If the developer is using JS or other framework. clientNavigation
should be false. interactive
in this case would not affect anything on the code. And for that, reason, all options are opt-out. (usually in this case, the user will not update or know about this value)
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core SVNIf you're a Core Committer, use this list when committing to
GitHub Merge commitsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
8d1718a
to
22ce41a
Compare
This reverts commit 78daef1185373c7153f060f580427d0331caa57e.
1f1d482
to
36d9491
Compare
What?
Add
clientNavigation
andinteractive
properties to block.json schema.Why?
When the Interactivity API is public, developers will need to indicate if their blocks are client side navigation compatible and interactive in their respective block.json files.
Client navigation will be opt out. Developers will need to set it as true if they want their block to work in client side navigation. (This means there is no interactivity or the block uses the Interactivity API to add interactions).
Testing Instructions