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

Block Hooks: Run block hooks on all block themes #45581

Merged
merged 6 commits into from Mar 21, 2024

Conversation

tjcafferkey
Copy link
Contributor

@tjcafferkey tjcafferkey commented Mar 14, 2024

This PR removes the guard for inserting WooCommerce's hooked blocks on approved themes only, if accepted this will allow us to hook blocks into all block themes.

Themes that were already approved:

  • Twenty Twenty-Four
  • Twenty Twenty-Three
  • Twenty Twenty-Two
  • Tsubaki
  • Zaino
  • Thriving Artist
  • Amulet
  • Tazza

Additional themes I've tested

  • Creatio 2
  • Attar
  • YITH Wonder
  • Raft
  • Blockbase (Since a lot of the themes are child-themes of Blockbase)

As you can see from the above we are already inserting out hooked blocks into the most popular themes which were the already approved ones. Based on my additional testing of themes that would be impacted after this change they all seem to handle the insertion of the Mini Cart well.

That said though there are a few cases (see screenshot below of the Attar themes default header) where we can continue to make improvements similar to how we did with TT4, TT3, TT2

attar-default-header

Submission Review Guidelines:

Changes proposed in this Pull Request:

Closes # .

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Install the themes I've listed under "Additional themes I've tested" and anymore you can get/find from the chart in the description.
  2. Test the Mini Cart auto-insertion on these themes header parts and patterns and that it looks acceptable.

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message Block Hooks: Run block hooks on all block themes instead of approved themes only.

Comment

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Mar 14, 2024
Copy link
Contributor

github-actions bot commented Mar 14, 2024

Test Results Summary

Commit SHA: 03d087c

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 38s
E2E Tests290006703577m 29s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@tjcafferkey tjcafferkey added team: Kirigami & Origami focus: FSE Issues related to Full Site Editing labels Mar 14, 2024
@tjcafferkey tjcafferkey self-assigned this Mar 14, 2024
@tjcafferkey tjcafferkey marked this pull request as ready for review March 14, 2024 14:46
@woocommercebot woocommercebot requested review from a team and imanish003 and removed request for a team March 14, 2024 14:47
Copy link
Contributor

Hi @imanish003,

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

@nerrad
Copy link
Contributor

nerrad commented Mar 18, 2024

Nice! Since we have the filter(s) available for patterns and themes, I wonder if we could start promoting this via developer.woo.com to encourage authors of block themes to test WooCommerce with their themes (and patterns). Instructions can be provided to exclude problematic patterns/themes in the post/docs?

Copy link
Contributor

@imanish003 imanish003 left a comment

Choose a reason for hiding this comment

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

Hey @tjcafferkey, Great work & thanks for adding block hook support for all themes 🚀

I've tested the changes across additional themes, and everything is working as anticipated. While I've observed a few minor issues, I believe most of them are within acceptable bounds. However, I wanted to highlight them to ensure they align with our expectations. I am pre-approving the PR as I don’t consider them as blockers 🙂

  • I noticed that the ‘Checkout header’ template parts doesn't have a mini-cart block in all themes. I believe that's expected, but I wanted to raise it here in case it's not.
    image

Here is what I noticed with themes & most themes have common observations:

YITH Wonder

  • Not all header template parts have mini-cart blocks, as you can see in the screenshot below. I believe this is expected, but I wanted to confirm with you.

image

Raft

  • As you can see in the screenshot below, There are two mini-carts. Also, bottom one's placement isn't great. Is that expected?

image

Blockbase

  • Having a breadcrumb in the middle feels somewhat off, though it's not a major issue. Ideally, it would be positioned alongside a mini-cart, preferably to the left of it. Your thoughts?

image

  • The placement of the mini-cart could be improved.

image

@@ -38,18 +38,9 @@ public function register_hooked_block( $hooked_blocks, $position, $anchor_block,
*
* @since $VID:$
*/
$pattern_exclude_list = apply_filters( 'woocommerce_hooked_blocks_pattern_exclude_list', array( 'twentytwentytwo/header-centered-logo', 'twentytwentytwo/header-stacked' ) );
$pattern_exclude_list = apply_filters( 'woocommerce_hooked_blocks_pattern_exclude_list', array( 'twentytwentytwo/header-centered-logo', 'twentytwentytwo/header-stacked', 'blockbase/header-centered' ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I am wondering if we should directly contribute to blockbase theme instead of excluding it here as Automattic owns it. Shouldn't themes leverage the woocommerce_hooked_blocks_pattern_exclude_list hook to exclude patterns instead of incorporating these exclusions within the WooCommerce core? 🧐

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should do both. Exclude it for now > Contribute > Include it back in. I'm leaving it excluded for now because if we want to fix this issue it'll fall quite low on the priority list for now and I'm unsure on timescales.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense to me 🤝

@tjcafferkey
Copy link
Contributor Author

tjcafferkey commented Mar 19, 2024

Nice! Since we have the filter(s) available for patterns and themes, I wonder if we could start promoting this via developer.woo.com to encourage authors of block themes to test WooCommerce with their themes (and patterns). Instructions can be provided to exclude problematic patterns/themes in the post/docs?

@nerrad This PR removes the filter for woocommerce_hooked_blocks_theme_include_list since we're removing the feature gate. I suppose we could replace it with an exclude list?

As for patterns we can put some documentation together for this, I agree it could be very useful.

I'll hold off merging this PR until you see this incase you foresee any problems with removing the filter or want us to replace it with a filter to exclude themes?

@nerrad
Copy link
Contributor

nerrad commented Mar 19, 2024

This PR removes the filter for woocommerce_hooked_blocks_theme_include_list since we're removing the feature gate. I suppose we could replace it with an exclude list?

I think replacing it with an exclude filter could be useful. It also provides an escape hatch for hosts/agencies that want finer control over auto-added blocks. With that said, is there a way in the WP core implementation to achieve similar functionality?

@tjcafferkey
Copy link
Contributor Author

With that said, is there a way in the WP core implementation to achieve similar functionality?

@nerrad they could add a filter (priority 999) to the hooked_block_types filter and either remove all hooked blocks or just woocommerce/ ones from the $hooked_blocks array.

This would be a better way to achieve the same thing I suppose because it keeps the 3PDs closer to the Core API which means less maintainability for Woo (we could explain this method in our post). It would cause less confusion too, when we explain we have our own filter for essentially doing the same thing.

@nerrad
Copy link
Contributor

nerrad commented Mar 19, 2024

Yup agreed. I'd prefer keeping our API surface small and this is something that could be surfaced in documentation if needed.

@tjcafferkey tjcafferkey merged commit e4017f0 into trunk Mar 21, 2024
59 checks passed
@tjcafferkey tjcafferkey deleted the remove-block-hooks-theme-include-list-guard branch March 21, 2024 08:25
@github-actions github-actions bot added this to the 8.8.0 milestone Mar 21, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Mar 21, 2024
@veljkho veljkho added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Mar 21, 2024
@nerrad
Copy link
Contributor

nerrad commented Apr 25, 2024

For future reference, here's a method to remove the auto-insertion of mini-cart block if it's not desired:

 add_filter( 'hooked_block_types', 'remove_mini_cart', 15, 1 );
function remove_mini_cart( $hooked_blocks ) {
	return array_filter(
		$hooked_blocks,
		function ( $block ) {
			return $block !== 'woocommerce/mini-cart';
		}
	);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: FSE Issues related to Full Site Editing needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris team: Kirigami & Origami
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants