-
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: migration to the new store()
API
#55459
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/class-wp-navigation-block-renderer.php ❔ lib/experimental/interactivity-api/class-wp-interactivity-store.php ❔ phpunit/blocks/render-query-test.php ❔ phpunit/experimental/interactivity-api/class-wp-interactivity-store-test.php |
Size Change: +1.63 kB (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
Flaky tests detected in d2d2e94. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7007797434
|
Sounds like a good plan. I think we can land this in 17.2 and work on One question: does |
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 think this is ready for prime time. Amazing work, @DAreRodz 🙂👏
I've left a few notes on some things that we could change before we merge, but some of them can also be addressed later if you want.
Do you mind adding an update to the Tracking Issue once you merge, and add the remaining tasks to the list? Thanks!
$p->set_attribute( 'data-wp-on--click', 'actions.core.query.navigate' ); | ||
$p->set_attribute( 'data-wp-on--mouseenter', 'actions.core.query.prefetch' ); | ||
$p->set_attribute( 'data-wp-effect', 'effects.core.query.prefetch' ); | ||
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' ); |
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 think for now it's fine to use the namespace manually here, althoug we need to think more about this. Maybe these blocks should also have a data-wp-interactive
directive as well.
I haven't tried it yet, but I just realised it shouldn't work because the generated I guess it will be better to update it in the |
Co-authored-by: Luis Herranz <luisherranz@gmail.com>
Can you make that change so at least people can use it until we replace |
Looking forward to trying these updates! |
We'll publish a migration guide in: |
* Copy new `store()` implementation * Enable TS for the interactivity API * Update directive bind tests * Update runtime with latest changes * Replace wp-effect tests with wp-watch tests * Update wp-body tests * Update wp-class tests * Update wp-context tests * Update wp-init tests * Fix wp-key assignment * Update wp-key tests * Update wp-on tests * Update directive priorities tests * Update directive slot tests * Update wp-style tests * Update wp-text tests * Update negation operator tests * Update router navigate tests * Refactor tests for router regions * Removed afterLoad tests * Fix initial state tag id * Update initial state tests * Update tovdom-islands tests * Update tovdom tests * Replace store with initial state in PHP * Fix wp prefixes in initial state * Add types declaration to package.json so that TS works * Add `wp-each` directive in the new store API * Add workaround for store API SDR * Modify children instead of replacing the element * Migrate File block to the new store API * Refactor Image block to use the new store API * Update runtime * Fix file namespace * Finish migrating the Image block * Update Navigation block * Replace effect with watch in Image * Fix namespace assignment * Fix image state getter names * Fix getters in navigation state * Update Query block * Fix directives for Navigation block * Add missing store namespace * Allow forward slashes in namespaces * Migrate Search block * Update Initial State and its tests * Revert "Add `wp-each` directive in the new store API" This reverts commit 51bf723. * Revert "Update Initial State and its tests" This reverts commit 7e5580c. * Revert "Replace store with initial state in PHP" This reverts commit 519880f. * Revert "Add workaround for store API SDR" This reverts commit 933c4ac. * Fix phpcs errors * Update Query phpunit tests * Fix Query's Interactivity API context definition * Fix action name in Navigation * Make `double()` prop a getter Co-authored-by: Luis Herranz <luisherranz@gmail.com> * Fix `double()` prop definition * Rename effects to callbacks in tests * Rename effects to callbacks in blocks * Rename effects to callbacks in unit tests * Move callbacks at the end of the store definition * Remove `layout-init` directive * Add default args for `openMenu` and `closeMenu` * Change Interactivity Store script tag ID --------- Co-authored-by: Michal Czaplinski <mmczaplinski@gmail.com> Co-authored-by: Mario Santos <santosguillamot@gmail.com> Co-authored-by: Luis Herranz <luisherranz@gmail.com>
Has this been backported to Core already? |
Yesss. |
What?
This PR migrates the runtime and core blocks to the new
store()
API, described in:Part of #53740.
Why?
The benefits of the new
store()
API are outlined in this discussion:How?
Interactivity API: implement the new
store()
API woocommerce/woocommerce-blocks#11071Testing Instructions
trunk
.