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

Filter to switch from the Interactivity API to the old implementation #52580

Conversation

luisherranz
Copy link
Member

What?

Add filters to switch from the Interactivity API to the old implementation of the Navigation and File blocks.

Follow up on #52553.

Why?

To be able to keep improving those versions, which are still in WP Core (more context).

How?

Just replace the IS_GUTENBERG_PLUGIN constant which was used to avoid merging the Interactivity API in Core with two filters, one for each block:

  • gutenberg_block_core_navigation_use_interactivity_api
  • gutenberg_block_core_file_use_interactivity_api

Testing Instructions

  • Add a Navigation block
  • Check that it works with the Interactivity API (check the network tab or accessibility improvements like aria-expanded switching to true on hover).
  • Add this filter somewhere in your code:
    add_filter( 'gutenberg_block_core_navigation_use_interactivity_api', '__return_false' );
  • Check that the Navigation block now works with micromodal (check the network tab or accessibility issues like aria-expanded not switching to true on hover).

@luisherranz luisherranz self-assigned this Jul 12, 2023
@luisherranz luisherranz added [Block] File Affects the File Block [Block] Navigation Affects the Navigation Block [Feature] Interactivity API API to add frontend interactivity to blocks. labels Jul 12, 2023
@luisherranz
Copy link
Member Author

@SantosGuillamot, I'd appreciate your review to make sure I didn't miss anything. Thanks 🙂

@luisherranz
Copy link
Member Author

Closing as duplicate of @westonruter's #52579.

@@ -471,7 +471,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
// - we don't have a relationship to a `wp_navigation` Post (via `ref`).
// ...then create inner blocks from the classic menu assigned to that location.
if (
defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN &&
apply_filters( 'gutenberg_block_core_navigation_use_interactivity_api', true ) &&
Copy link
Member

Choose a reason for hiding this comment

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

Is this right? The code in here is not all related to Interactivity API.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, but let's use your PR instead: #52579

@github-actions
Copy link

Flaky tests detected in d762b95.
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/5534847419
📝 Reported issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] File Affects the File Block [Block] Navigation Affects the Navigation Block [Feature] Interactivity API API to add frontend interactivity to blocks.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants