Skip to content
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

Epic: Interactivity API - public 1.0 version #56803

Closed
45 of 47 tasks
luisherranz opened this issue Dec 5, 2023 · 45 comments
Closed
45 of 47 tasks

Epic: Interactivity API - public 1.0 version #56803

luisherranz opened this issue Dec 5, 2023 · 45 comments
Labels
[Feature] Interactivity API API to add frontend interactivity to blocks. [Type] Iteration Scoped iteration of an effort from a tracking issue or overview issue ideally for a major release.

Comments

@luisherranz
Copy link
Member

luisherranz commented Dec 5, 2023

In More core blocks and new store() API, we first worked on preparing Core blocks for WP 6.4, including the new enhanced pagination of the Query block, and after the release of WP 6.4, we also worked on the migration of the new store() API.

For this iteration of the Interactivity API, we want to focus on the preparation of a 1.0 version that can be released publicly in WordPress Core and serve as the base for future enhancements.

We also want to consolidate here the work of the Tracking Issue: Server Directive Processing to keep all the implementation work under the same issue, but we will keep tracking the documentation-related tasks in the Documentation Tracking Issue.

Tasks

This is the list of initial tasks, although we will edit this post as we progress and discover other things that we need to do.

@luisherranz luisherranz added [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues. [Feature] Interactivity API API to add frontend interactivity to blocks. labels Dec 5, 2023
@gziolo gziolo mentioned this issue Dec 6, 2023
58 tasks
@priethor priethor added [Type] Iteration Scoped iteration of an effort from a tracking issue or overview issue ideally for a major release. and removed [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues. labels Dec 7, 2023
@priethor priethor changed the title Tracking Issue: Interactivity API - public 1.0 version Epic: Interactivity API - public 1.0 version Dec 7, 2023
@cbravobernal
Copy link
Contributor

The directive processing of only interactive blocks is ready for review. I will add more tests during this week.

@felixarntz
Copy link
Member

Related to the server-side directive processing and the above PR #56302, are there any plans to provide an API function that is decoupled from blocks? I think there are many use-cases (primarily classic "hard-coded" HTML in core, plugins, and themes) that could use the Interactivity API. If such use-cases could then call a simple function to process the directives on the HTML string, that would be really helpful.

Potentially the function gutenberg_process_interactive_html() introduced in #56302 could be what I'm looking for? As far as I can tell, the only block specific part is $inner_blocks which could be omitted?

@luisherranz
Copy link
Member Author

@felixarntz yeah, we're still trying different things here. To be honest, I'm not very happy with the current approach. And as you say, it's quite coupled with blocks.

I think we can simplify it to process only on the "root interactive blocks" and try to encapsulate everything in a single function. Maybe something like this that also classic themes could use:

$html = do_interactivity( $html );

To do so, we need to get rid of all the things that depend on knowing which part of the HTML belongs to which block during the processing (like private stores), but I think it's doable and it will simplify things.

What do you think?

@felixarntz
Copy link
Member

Thanks @luisherranz, that sounds like a good plan to me. I have to admit, my understanding of private stores is quite limited still. But what you're saying sounds solid as far as I can assess.

Regarding a function name, I'd prefer to do away with the "do" prefix. While it's sort of common for some WP processing functions, I think it's also somewhat legacy. I would find something like process_interactivity or parse_interactivity or parse_interactivity_directives more suitable. But a function name is probably the last challenge in this 😆

@luisherranz
Copy link
Member Author

Haha, sure. That's because I was thinking about do_blocks, but those names sound good to me. Let's see if we can condense everything into a single function 🙂

@cbravobernal
Copy link
Contributor

cbravobernal commented Jan 12, 2024

Added a PR to render the root interactive blocks in Server Directives Processing. Ready to review!

@DAreRodz
Copy link
Contributor

I created a PR to implement the data-wp-run directive. I saw it convenient to include also the hooks useWatch and useInit in the same PR. Ready for review.

@luisherranz
Copy link
Member Author

The PR with wp_initial_state was merged:

@cbravobernal
Copy link
Contributor

Created two PRs that remove directives that are not being used:

I labeled them as breaking changes, in case some external developers have been using them.

@DAreRodz
Copy link
Contributor

The wp-run directive implementation, the new useWatch and useInit hooks, and the scoped version of all callback-based hooks have been recently merged.

@cbravobernal
Copy link
Contributor

Prevent using components in data-wp-text is ready for review:

@DAreRodz
Copy link
Contributor

I'm currently working on the data-wp-each directive. Only the documentation needs to be included at this point.

I'll set the PR ready for review shortly.

@cbravobernal
Copy link
Contributor

cbravobernal commented Jan 16, 2024

I'm currently working on the upgrade of the dependencies. Is still draft, as needs some testing and I found the role in navigation is only appearing at the second click on the open button. Working and merged.

@DAreRodz
Copy link
Contributor

I've opened a new PR to move all the logic related to the ARIA live region and the loading bar from the Query block to the Interactivity Router. Ready for review.

@Tropicalista
Copy link

Can someone please clarify what is the name of the function for a default store in PHP?

In previous release was wp_store, then changed to wp_initial_state. Now it seems it's renamed to wp_interactivity_state.

Can we please specify this in docs as well?

#58436

@luisherranz
Copy link
Member Author

@Tropicalista: yes, we've renamed the function. I'll make a PR to update the docs once GB 17.6 is released with the final name.

Please follow the changelog and breaking changes discussion to get the latest updates on how the API evolves.

@DAreRodz
Copy link
Contributor

I have opened a draft PR to fix the initial page cache in the @wordpress/interactivity-router module.

@luisherranz
Copy link
Member Author

I opened a PR that adds a server processor for data-wp-each:

@luisherranz
Copy link
Member Author

Small update.

  • The last two server directive processors (data-wp-each and data-wp-router-region) have been merged.
  • The navigate function now triggers the loading bar and screen reader announcement by default.

Remaining tasks:

  • Query block: switch from data-wp-navigation-disabled to config['core/router'].clientNavigation = false
  • Image block: see if we can remove the data-wp-body directive.
  • Other small tweaks.

@cbravobernal
Copy link
Contributor

cbravobernal commented Feb 6, 2024

Added a PR with some small changes in comments. And refactors to TS.

@DAreRodz
Copy link
Contributor

DAreRodz commented Feb 6, 2024

I've created a PR to make all core block stores private.

It includes a bugfix that solves a problem with the async initialization of private stores.

@luisherranz
Copy link
Member Author

I've opened a PR to support data-wp-interactive="myPlugin".

@DAreRodz
Copy link
Contributor

DAreRodz commented Feb 6, 2024

Here, a draft PR that implements global configs in the JS runtime:

It also gets rid of the data-wp-navigation-disabled attribute we were adding to Query blocks when they contain unsupported blocks. Instead, a property clientNavigation inside the core/query config is used.

EDIT: the PR is ready for review now.

@DAreRodz
Copy link
Contributor

DAreRodz commented Feb 7, 2024

I have updated the task list to mark "Populate state.url from the server" as complete, explaining that we decided not to implement that and keep the logic that initializes it from JS in @wordpress/interactivity-router.

@DAreRodz
Copy link
Contributor

DAreRodz commented Feb 8, 2024

This PR limits the exposed API from @wordpress/interactivity:

@luisherranz
Copy link
Member Author

I opened a PR to remove the data-wp-body directive and refactor the Image block to add the overlay using wp_footer instead:

@mtias
Copy link
Member

mtias commented Feb 9, 2024

Regarding one meta aspect of how we communicate this functionality more broadly, I think Interactivity API is ok as the technical aspect for developers, but when we talk broadly about what it does I think we should refer to it as Interactions. Interactions is the feature, and it's powered by this new developer API.

So similar to block API -> blocks we'll have interactivity API -> interactions. I find that clearer and easier than interactivity on its own, but curious what others think. I don't believe this has any material considerations on namespace issues at the code level, except perhaps the possibility of renaming the entry package to @wordpress/interactions.

@ajgagnon
Copy link

ajgagnon commented Feb 9, 2024

Regarding one meta aspect of how we communicate this functionality more broadly, I think Interactivity API is ok as the technical aspect for developers, but when we talk broadly about what it does I think we should refer to it as Interactions. Interactions is the feature, and it's powered by this new developer API.

So similar to block API -> blocks we'll have interactivity API -> interactions. I find that clearer and easier than interactivity on its own, but curious what others think. I don't believe this has any material considerations on namespace issues at the code level, except perhaps the possibility of renaming the entry package to @wordpress/interactions.

This would need careful consideration, for sure. Having 2 names for the same functionality can also make things less clear in some cases. There is currently this issue with people referring to the "WordPress Block Editor" as "The Gutenberg Editor". Maybe `interactivity API -> interactivity"? Just a thought.

@cbravobernal
Copy link
Contributor

Added a PR to fix directives not being processed if the HTML contained a SVG or a MATH.

@fabiankaegy
Copy link
Member

Now that we are past the Beta 1 cut off point I'm removing this tracking issue from the 6.5 Project board. From now on the board should only contain individual bugs that we want to still fix before 6.5 gets released.

@gziolo
Copy link
Member

gziolo commented Feb 20, 2024

Should we also close the issue an open separate issues for remaining tasks so those applicable can be put on the 6.5 board and tackled before 6.5 Beta 3 scheduled for Tuesday next week?

@cbravobernal
Copy link
Contributor

I will miss this tracking issue 😅, but yep, I will do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Interactivity API API to add frontend interactivity to blocks. [Type] Iteration Scoped iteration of an effort from a tracking issue or overview issue ideally for a major release.
Projects
None yet
Development

No branches or pull requests