Repository navigation
Description
- Part of Block API #41236.
In WordPress 6.6, work was done to improve warnings integration with Preact DevTools, as well as adding directives for asynchronous event handlers and support for derived state on the server.
In WordPress 6.7, we will continue working on internal improvements to ensure that the Interactivity API's code is as simple and stable as possible and to make the Interactivity API resilient when used asynchronously (e.g., adding directives or stores after initialization). This will pave the way for performance improvements such as directive code splitting or lazy loading of interactive blocks.
In Core blocks, work will begin on the Gallery block lightbox and the Query block's Instant Search.
Apart from the work for WordPress 6.7, investigations will continue, with the most important being the exploration of how to improve assets management in region-based client-side navigation and experimenting with full-page client-side navigation. However, those will be tracked in its own Tracking Issue.
Work is also continuing to improve the documentation with enhancements in the API Reference and new explanatory guides tracked in the Interactivity API documentation's Tracking Issue.
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.
Enhancements
- Refactor internal proxy and signals system
- Refactor the
deepMergelogic - Refactor internal context proxy
- Add support for
getServerStateandgetServerContext - Refactor types, support generator <-> promise transformations, add tests and fix overloads
- Add
wp_interactivity_get_elementso it can be used in the derived state Closures to inspect the element attributes with$element['attributes'](using$p->get_attributes_with_prefix('')). - Lazy loading of interactive blocks
- Introduce
withSyncEventand require Interactivity API actions that use theeventobject to use it #64944
Core blocks (optional)
- Query and Search blocks: Instant Search
- Gallery block: Lightbox
- Accordion block
- Tabs block
Bug fixes
- iAPI: Merge of state and context after client-side navigation #63864
- Interactivity: Fix
withScopeto restore scope on thrown exception inside async functions #62555 -
Cannot bind attributes to direct children ofdata-wp-each#60981 - Interactivity API: Inability to use plain arrays in context #63651
- Interactivity API: Fix context inheritance from namespaces different than the current one #64677
- Interactivity API: Prevent calling
proxifyContextwith context proxies insidewp-context#65090 - Interactivity API: Update iterable signals when
deepMerge()adds new properties #65135 - Interactivity API page restoring breaks embedded SPA apps with routing #60455
- iAPI Router: don't remove region when it's not present in the new page #63249
- iAPI: Enforce correct namespaces in all places (directives, functions…) that accept a namespace #63749
Optional
- Add tests fro
getElement()attributes - Official syntax for unique-ids
- Review all errors and make them more consistent
- Allow async directive registration
- Show directive names in Preact's dev tools
- Keep improving TypeScript support
- Support for
data-wp-client-only-component - Support handling
navigate()failure states
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone 😃
- StatusShow more project fields✅ Done
Activity
[-]Tracking Issue: Interactivity API in WP 6.7[/-][+]Interactivity API iteration for WordPress 6.7[/+]adamsilverstein commentedon Jul 8, 2024
Can you also consider #60522?
luisherranz commentedon Jul 9, 2024
I thought that work was still experimental since it requires using Chrome Canary. But if you think it should be included in WordPress 6.7, sure, we can include it 🙂
adamsilverstein commentedon Jul 9, 2024
true, it is still experimental and thus maybe not ready for 6.7!
I'm hoping it lands in stable soon and this is a purely debugging related feature. Mostly I don't want the work to fall off the radar and I thought to some degree experimental features where acceptable in Gutenberg since we can always pull them before merging into core.
luisherranz commentedon Jul 9, 2024
Ok, then let's leave it out of the list of things for WordPress 6.7 but let's keep an eye on including it in future versions once the APIs are stable 🙂
Sure, if you want to merge it in Gutenberg to test it out, that's totally fine.
adamsilverstein commentedon Jul 9, 2024
That is indeed exactly what I want to do - in part the goal here is to give the team building the feature (DevTools performance panel extensibility API or "User Timings") feedback about what is useful and what is missing. By testing the feature out in Gutenberg, we can influence how it being built before it lands in stable.
ajgagnon commentedon Jul 22, 2024
Any chance of getting a
data-wp-ifdirective included? It would be immensely helpful. Happy to attempt a PR if this is in the scope.luisherranz commentedon Jul 22, 2024
Yeah, a
data-wp-showdirective is on the roadmap indeed.If you're willing to work on it we'd love to help you out. As far as I remember, the work not only requires the client-side directive implementation, but also an extra function similar to this one for the server-side rendering.
But we can discuss the details in a proper issue or in Slack 🙂
ajgagnon commentedon Jul 22, 2024
Sure! I had left a comment there on the original issue here:
#53058 (comment)
It looks like the scope has not been decided yet, so that seems like the first item needed.
6 remaining items
sethrubenstein commentedon Aug 30, 2024
@luisherranz Can you share a little bit about what
getServerStateand whatgetServerContextwill do?luisherranz commentedon Aug 30, 2024
Sure! Since it's not possible for the initial server state to overwrite the client state because that approach is not compatible with region-based client-side navigation, we need an API for use cases where, after navigating, you want to inspect the initial state or context of the new page.
So those two functions will return the initial state or context that came from the server and they are reactive, so that initial state or context updates every time there is a client-side navigation. People would normally use them in a
data-wp-watch. For example:That's it! The same for state using
getServerState.@DAreRodz will open a pull request next week, and we appreciate any feedback and assistance testing this new API, that if everything goes well, would make it into WP 6.7 😄
madhusudhand commentedon Sep 2, 2024
Gallery block is close to getting merged. It is pending with following feedback
inertpointed here 🚧I am looking into the second feedback item. Hopefully it will be resolved this week.
annezazu commentedon Sep 3, 2024
Sweet! I'll add the Gallery block back onto the 6.7 roadmap.
DAreRodz commentedon Sep 9, 2024
Updates
I've added the following bug fixes to the tracking issue:
proxifyContextwith context proxies insidewp-context#65090deepMerge()adds new properties #65135The first bug was a regression introduced in #62734, and it's merged and ready for the next Gutenberg RC. The second one is a missing piece of logic we forgot to include in #64879. It's ready for review.
The following PR is also ready for review. I've introduced a change that depends on #65135 being merged; the failing test should pass after that.
As the next step, I have to open a PR for
getServerContext()andgetServerState(), which is currently WIP.DAreRodz commentedon Sep 9, 2024
I've just created a draft for the
getServerContext()andgetServerState()functions.getServerState()andgetServerContext()#65151michalczaplinski commentedon Sep 11, 2024
I've created a new issue to discuss the
getServerState()&getServerContext()APIs: #65243madhusudhand commentedon Sep 17, 2024
@annezazu The current approach we took for gallery block is rendering translations on server (because
i18nisn't available as script module), which is observed to be complex and is not a good example/practice for the community.I think we should punt it to 6.8
annezazu commentedon Sep 17, 2024
Thanks for the update! Agreed. Let’s punt.
gziolo commentedon Sep 20, 2024
#65151 landed this week and contains a new public API 🎉As it's going to be included in WordPress 6.7, it will need an accompanying dev note (added label) and documentation in the Interactivity API reference.
gziolo commentedon Nov 19, 2024
WordPress 6.7 “Rollins”, which contains all the finished work, was released last week. The work for unfinished but still applicable tasks will continue in the new iteration issue created in the following days.
luisherranz commentedon Nov 25, 2024
Work continues in