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

Server directive processing: Process only root blocks #55739

Merged
merged 9 commits into from
Nov 8, 2023

Conversation

cbravobernal
Copy link
Contributor

Co-authored with @luisherranz

What?

Create a "root blocks" identifier, so the Interactivity API will only process the directives of these ones.
When we process the directives in PHP of a block that contains inner blocks, we already have the entire HTML, so, in order to prevent the function to run on a inner block render, we need a function to retrieve only the root blocks.

Testing Instructions

Unit tests are included in the PR

Testing Instructions for Keyboard

Screenshots or screencast

Screenshot 2023-10-31 at 18 35 20

Copy link

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/experimental/interactivity-api/directive-processing.php
❔ phpunit/experimental/interactivity-api/directive-processing-test.php

@luisherranz
Copy link
Member

Let's get rid of the global. We can use the same pattern we used here, with a function hooked to render_block_data that has some static variables that are passed down to a second function created inside the first one and hooked to the render_block filter.

@cbravobernal
Copy link
Contributor Author

cbravobernal commented Nov 2, 2023

Sure, I'll update it and ping when is ready.

@cbravobernal cbravobernal force-pushed the experiment/process-only-root-blocks branch 2 times, most recently from 34d60b0 to 705448b Compare November 7, 2023 11:11
@luisherranz luisherranz changed the title Experiment/process only root blocks Process only root blocks Nov 7, 2023
@luisherranz luisherranz changed the title Process only root blocks Server directive processing: Process only root blocks Nov 7, 2023
@luisherranz luisherranz added [Feature] Interactivity API API to add frontend interactivity to blocks. [Type] Enhancement A suggestion for improvement. labels Nov 7, 2023
@cbravobernal cbravobernal marked this pull request as ready for review November 7, 2023 16:30
Copy link

github-actions bot commented Nov 7, 2023

Flaky tests detected in 72686e2.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6796476784
📝 Reported issues:

@luisherranz
Copy link
Member

The e2e interactive tests are failing.

Copy link
Member

@luisherranz luisherranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The e2e tests should be fixed now.

On second thought, I don't love this unit test because it's coupled with the implementation and won't be useful when we switch to processing the directives using other methods, but I think it's good enough for now.

Let's merge this to keep things moving 🙂

@luisherranz luisherranz enabled auto-merge (squash) November 8, 2023 09:13
@luisherranz luisherranz force-pushed the experiment/process-only-root-blocks branch from b51a282 to 448c391 Compare November 8, 2023 09:17
@luisherranz luisherranz merged commit f8cfba6 into trunk Nov 8, 2023
49 checks passed
@luisherranz luisherranz deleted the experiment/process-only-root-blocks branch November 8, 2023 12:44
@github-actions github-actions bot added this to the Gutenberg 17.1 milestone Nov 8, 2023
@youknowriad
Copy link
Contributor

Has this been backported to Core already?

@luisherranz luisherranz added the Backported to WP Core Pull request that has been successfully merged into WP Core label Feb 8, 2024
@luisherranz
Copy link
Member

Yesss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core [Feature] Interactivity API API to add frontend interactivity to blocks. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants