WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.57k stars 4.22k forks source link

Tracking Issue: Prepare the private version of the Interactivity API for WP 6.4 #54291

Closed luisherranz closed 1 year ago

luisherranz commented 1 year ago

WP 6.4 will include Gutenberg up to the 16.7 version, which includes the new Image Lightbox, an enhanced pagination for the Query block and accessibility fixes for the Navigation block, all of them powered by the Interactivity API. Although the Interactivity API is still in the proposal phase, we can include a private version that only Core blocks can access in WP 6.4 to release these features/enhancements.

Please note that the Interactivity API is still likely to change before the final public version is released, but by keeping it private to Core blocks in WP 6.4, we can still modify it before it's public. Furthermore, if the proposal is finally rejected for some reason, we just have to replace the Interactivity API implementation of the Core blocks with whatever new approach is adopted instead.

The release of the 16.7 RC is scheduled for the 20th of September. Before that date, we need to complete the following tasks:

SantosGuillamot commented 1 year ago

I created this pull request to remove gutenberg_should_block_use_interactivity_api and the old implementation of the Navigation and File blocks. In the end, I decided to do everything simultaneously because of some related conditionals.

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

luisherranz commented 1 year ago

Approved! Thanks, Mario πŸ‘

luisherranz commented 1 year ago

I've opened a PR to test the WP Core webpack configuration. It's not finished yet, but so far it seems to be working great:

SantosGuillamot commented 1 year ago

I've opened a PR to add manual SSR to the Navigation block and the File block. As explained in the pull request, I believe that in the File block, it is complicated to replicate the JS logic, so we have to make a decision there.

SantosGuillamot commented 1 year ago

I've been reviewing the Search block PR, and I think it should be ready to be merged, it needs review and approval. I also modified it so it works without the Interactivity API SSR.

DAreRodz commented 1 year ago

I've opened a draft PR for disabling the enhanced pagination if third-party blocks exist in the Post Template.

luisherranz commented 1 year ago

I've added a new task for the Query block:

SantosGuillamot commented 1 year ago

I've created a pull request to remove the usage of wp_store in the Query block:

SantosGuillamot commented 1 year ago

The PR to move the Search block to the Interactivity API has been merged:

luisherranz commented 1 year ago

I've sucessfully finished modifying the Webpack files to make @wordpress/interactivity a private package:

The next step is to try to test it out in WP Core. I've also added a couple of related tasks to the opening post.

luisherranz commented 1 year ago

I've ported the changes to WordPress Core and they are working great. This should be ready to merge once the sync between Gutenberg and WP Core happens (with the correct modifications to the PR).

luisherranz commented 1 year ago

@artemiomorales, @michalczaplinski: @tellthemachines mentioned me that we need to review the usage of WP_Theme_JSON_Resolver_Gutenberg in the Image block before the 16.7 RC release (20th of Sept).

This is the exact message:

We're calling WP_Theme_JSON_Resolver_Gutenberg in the Image block PHP file, which isn't defined in core. We'll need to add some logic similar to this to check if the core class exists.

I've added to the list of tasks in the opening post. Please take care of it and mark it as ready afterward. Thanks πŸ™‚

luisherranz commented 1 year ago

I've opened an issue with some design enhancements mentioned by @jasmussen. There are some that we should do before the 16.7 RC release, and others that we can try if we have time:

DAreRodz commented 1 year ago

The changes to allow only core blocks inside a Query Loop with enhanced pagination are done and merged.

I'll continue with the rest of the enhancements.

DAreRodz commented 1 year ago

This addresses most of the design feedback from @jasmussen. πŸ‘‡

It's ready for review.

DAreRodz commented 1 year ago

I've created another PR that adds a timeout option to navigate(), with a default value of 10000 milliseconds (10 seconds).

luisherranz commented 1 year ago

David opened another PR to improve the accessibility of the modal:

luisherranz commented 1 year ago

Open PR in Gutenberg to add this code to each interactive block to make sure that all the scripts have the wp-interactivity dependency

I think it's safe to do this in WordPress itself. I'll add it to this PR instead: (see below)

michalczaplinski commented 1 year ago

We're calling WP_Theme_JSON_Resolver_Gutenberg in the Image block PHP file, which isn't defined in core. We'll need to add some logic similar to this to check if the core class exists.

This issue was fixed by merging https://github.com/WordPress/gutenberg/pull/53851 which removes the reference to WP_Theme_JSON_Resolver_Gutenberg in the Image block. There is another reference to WP_Theme_JSON_Resolver_Gutenberg in https://github.com/WordPress/gutenberg/blob/62c1f50704d7b2235a525e121d5ee6ea0bc449e1/lib/block-supports/behaviors.php#L67 which is temporarily added to Gutenberg for backward-compatibility and will be removed in GB 17.0.

SantosGuillamot commented 1 year ago

I've created a PR to handle the remaining tasks related to the lightbox:

tellthemachines commented 1 year ago

Open PR in Gutenberg to add this code to each interactive block to make sure that all the scripts have the wp-interactivity dependency

I think it's safe to do this in WordPress itself. I'll add it to this PR instead:

@luisherranz does this require changes to block PHP files? If so, it has to be done in Gutenberg. The block PHP gets generated in core from the block-library package so it can't be manually edited there.

luisherranz commented 1 year ago

@luisherranz does this require changes to block PHP files?

No, it doesn't. We can add it in Core in wp-includes/script-loader.php if that's ok.

EDIT: I tried, but I think it's simpler to add it here in Gutenberg:

luisherranz commented 1 year ago

I added logic to start prefetching the next pages on the first click to the next and previous buttons:

DAreRodz commented 1 year ago

I opened a PR that shows a subtle animation when the HTML is updated and changes the scroll behavior to smooth during navigation. Ready for review.

ermincelikovic commented 1 year ago

Hi folks, thanks for the good work!

I just wanted to understand better - Interactivity API is not going to be useable outside of WP Core in 6.4? Does it mean it is planned for 6.5?

SantosGuillamot commented 1 year ago

I just wanted to understand better - Interactivity API is not going to be useable outside of WP Core in 6.4? Does it mean it is planned for 6.5?

Yes, in 6.4, only core blocks can use the Interactivity API. If you want to use the Interactivity API for your custom blocks, you need to install the Gutenberg plugin as well. We considered it safer this way because there are some parts that need more testing and the API is likely to change. So it might require developers who built custom blocks using the API to change the syntax.

On the other hand, if everything goes as expected, the idea is to make it public in WP Core in 6.5 as you say.

luisherranz commented 1 year ago

Even though there's still some discussion about the fading animation of the Query block, I'm going to close this Tracking Issue as finished because WP 6.4 Beta 1 has already been released.

We will continue working in the new store() API, please follow the progress in this Tracking Issue: