-
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 docs: Add wp-async directives doc #62663
Conversation
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 If 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. |
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.
Thank you for adding these!
Should there also be notes added to the wp-on
, wp-on-window
, and wp-on-document
sections to call out the async alternatives?
@@ -383,6 +392,10 @@ store( "myPlugin", { | |||
|
|||
The callback passed as the reference receives [the event](https://developer.mozilla.org/en-US/docs/Web/API/Event) (`event`), and the returned value by this callback is ignored. When the element is removed from the DOM, the event listener is also removed. | |||
|
|||
### `wp-on-document-async` | |||
|
|||
Similar to `wp-on-async`. An optimized version of `wp-on-document` that prevents blocking the main thread on long tasks. Use this directive for any `wp-on-document` that doesn't need the `event` object (`event.preventDefault()`, `event.stopPropagation()`, etc.) |
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.
Similar to `wp-on-async`. An optimized version of `wp-on-document` that prevents blocking the main thread on long tasks. Use this directive for any `wp-on-document` that doesn't need the `event` object (`event.preventDefault()`, `event.stopPropagation()`, etc.) | |
Similar to `wp-on-async`. An optimized version of `wp-on-document` that prevents blocking the main thread on long tasks. Use this directive for any `wp-on` that doesn't need synchronous access to the `event` object, in particular the methods `event.preventDefault()`, `event.stopPropagation()`, and `event.stopImmediatePropagation()`. This event listener is also added as `passive`. |
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.
Done in e3b0497
See also #62665 which would impact the docs here, especially the "async actions" section. |
Flaky tests detected in e3b0497. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9571563158
|
* Add wp-async directives doc * Changes requested * Add notes to use async and further refine copy * Add links including to async actions section * Add async action example which yields to the main thread --------- Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org> Co-authored-by: westonruter <westonruter@git.wordpress.org>
I just cherry-picked this PR to the wp/6.6-rc-1 branch to get it included in the next release: c8372ed |
* Add wp-async directives doc * Changes requested * Add notes to use async and further refine copy * Add links including to async actions section * Add async action example which yields to the main thread --------- Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org> Co-authored-by: westonruter <westonruter@git.wordpress.org>
What?
Add documentation for
data-wp-async
directives.Completes #61885