-
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: Increase directive wp-each-child
priority.
#62293
Conversation
That's a nice and easy fix. 😄 Not sure if we should add tests to this, as the directive priority levels are already tested in
Regarding this approach (I suggested it 😅), I think it would be unnecessarily complex and wouldn't solve the problem in the browser if, for some reason, the HTML is broken (I mean, HTML that contains an element with |
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.
I don't understand how this was working. Did we have this bug from the beginning? Is this in WP 6.5?
We should at least add one test, by the way 🙂
Flaky tests detected in 0d9edda. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9379574276
|
Checking in on PRs with the Backport to Gutenberg RC. I'll release 18.5 later today, do you think this'll make it in time? |
The e2e test is a little tricky. I'm not sure we will make it. |
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❔ packages/e2e-tests/plugins/interactive-blocks/directive-each/render.php |
Size Change: +645 B (+0.04%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
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 refactored the test a bit and ensured it only passed with the fix. LGTM!
Changes applied. Only a test is required, that should not block the release.
I just cherry-picked this PR to the release/18.5 branch to get it included in the next release: af2e67a |
* Increase directive priority * Increase directive priority * Add e2e test * Refactor e2e test --------- Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org> Co-authored-by: DAreRodz <darerodz@git.wordpress.org> Co-authored-by: luisherranz <luisherranz@git.wordpress.org> Co-authored-by: vcanales <vcanales@git.wordpress.org>
* Increase directive priority * Increase directive priority * Add e2e test * Refactor e2e test --------- Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org> Co-authored-by: DAreRodz <darerodz@git.wordpress.org> Co-authored-by: luisherranz <luisherranz@git.wordpress.org> Co-authored-by: vcanales <vcanales@git.wordpress.org>
* Increase directive priority * Increase directive priority * Add e2e test * Refactor e2e test --------- Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org> Co-authored-by: DAreRodz <darerodz@git.wordpress.org> Co-authored-by: luisherranz <luisherranz@git.wordpress.org> Co-authored-by: vcanales <vcanales@git.wordpress.org>
…Press#62293) * Increase directive priority * Increase directive priority * Add e2e test * Refactor e2e test --------- Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org> Co-authored-by: DAreRodz <darerodz@git.wordpress.org> Co-authored-by: luisherranz <luisherranz@git.wordpress.org> Co-authored-by: vcanales <vcanales@git.wordpress.org>
This was cherry-picked to the wp/6.6 branch. |
What?
Co-authored with @DAreRodz, bug found by @zaguiini
Increase
data-wp-each
priority to fix trying to process non existent elements in the dom.Why?
To add some context, the
data-wp-each-child
directive is intended to remove the node in which it appears. Why? Becausedata-wp-each
is the one that actually renders it.The issue is that it has the same priority level as most directives, and they are grouped into the same
Directives
component and evaluated together. Thus, even though the component returnsnull
, all its hooks are evaluated, i.e., the ones thatdata-wp-bind
,data-wp-on
etc., register. Also, thedata-wp-each
server-side processing maintains the directives that appear in child nodes. 😬That's why the element is
null
inside theuseInit
hook called indata-wp-bind
; because it is. The thing is thatdata-wp-bind
should not be evaluated (nor other directives).How?
One quick fix for this issue is to increase the
data-wp-each-child
priority, being the first one in being evaluated.Other fix could be not to server side render the directives in the content created by the template tag, in the
data-wp-each
SSR processing. I did not measure it, but being that content already evaluated, adding the directives in the SSR should be triggering a not needed re-evaluation.Testing Instructions
wp-each
SSR, like this one:trunk
, an error appears on the console.Screenshots or screencast
PR not applied
PR applied
Leaving the PR on draft until we decide which approach is better.