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

[Experimental] Use variations to provide all the product filters wrapped by CollectionFilters block #43216

Merged
merged 14 commits into from
Jan 4, 2024

Conversation

samueljseay
Copy link
Contributor

Changes proposed in this Pull Request:

To support discoverability and simplify adding filters this PR registers each of the new interactivity filters as a variation of the collection-filters block and inside the block we choose a template for the respective filter based on an attribute passed in the variant.

Closes #42160

How to test the changes in this Pull Request:

  1. In the block editor the filter blocks by themselves should not show in the block inserter
  2. These new block variants should show
  3. try adding each one of the new variants
  4. It should add a collection filters wrapper and a corresponding heading for the block

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

[Experimental] Use variations of collection filter to provide new interactivity based filter blocks.

Comment

@woocommercebot woocommercebot requested a review from a team January 2, 2024 10:36
Copy link
Contributor

github-actions bot commented Jan 2, 2024

Hi @dinhtungdu,

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

Copy link
Contributor

github-actions bot commented Jan 2, 2024

Test Results Summary

Commit SHA: 442e98a

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 36s
E2E Tests258003026113m 43s

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.

@samueljseay samueljseay removed the request for review from a team January 3, 2024 01:18
Copy link
Member

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

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

Thanks for working on this PR! This is working as expected according to the testing instructions. I don't have any comment codewise but about one on the behavior:

In the block editor the filter blocks by themselves should not show in the block inserter

I don't think we should do this, because:

  • The filter blocks are only available inside Collection Filters block, so they don't add more noise to the global inserter.
  • With this PR, when adding inner blocks to Collection Filters, for example Price Filter, we're adding another Collection Filters block and Price Filter blocks to the original Collection Filters block.

I think the behavior should be:

  • Collection Filters block shouldn't be available inside other Collection Filters block.
  • The new variations added in this PR also shouldn't be available inside Collection Filters block.
  • The inserter visibility of new filter blocks should be restored as they are before, only available inside Collection Filters block.
  • In the other words, we should disallow the following blocks inside Collection Filters, so when inside that block, the only result, price filter for example, should be the new price filter block:
    • Filter Wrapper variations (we will disable legacy blocks soon so this may not necessary).
    • Collection Filters block and its variations.

Sadly, Gutenberg hasn't provided any API to disallow specific inner blocks right now, so we have to either:

  • use a fix list of allowed blocks, which includes new filter blocks and blocks for layout purpose.
  • use a dynamic list of allow blocks (defining the list at run time).

…branch (#43207)

Set WOOCOMMERCE_BLOCKS_PHASE to experimental when building PR live branch.
@github-actions github-actions bot added package: @woocommerce/components issues related to @woocommerce/components plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Jan 3, 2024
@samueljseay samueljseay force-pushed the dev/implement-inserter-behavior branch from 3cfea8e to d3e7b7b Compare January 3, 2024 09:16
@github-actions github-actions bot removed the package: @woocommerce/components issues related to @woocommerce/components label Jan 3, 2024
@samueljseay
Copy link
Contributor Author

samueljseay commented Jan 3, 2024

@dinhtungdu I took another go at this based on your feedback. Hurts the head a little when dealing with variants and such but let me try explain the behavior implemented. If you could test and see if what I've implemented here matches your expectations :)

  1. Collection filters can be inserted. It has default variant which includes all the new filter blocks

  2. Collection filters cannot be inserted in collection filters

  3. The filters themselves can still be inserted at top level of collection filters though

  4. The filter variants cannot be nested in filter variants (again avoiding nested collection filters)

  5. The inserter false is removed now and you can use variants to add the collection-filter -> filter hierarchy

  6. By disallowing woocommerce/filter-wrapper we disallow adding any of the old filters

I think that about sums it up.

I expect we can fix up any block naming as part of #43167

Copy link
Member

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

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

Great update! Having the Collection Filters inserts all filter blocks by default is a good UX 💯 .

In my test, I can still insert variation inside another variation. Here is the testing video taken on https://shy-kingfisher.jurassic.ninja/

Screen.Recording.2024-01-03.at.18.12.09.mov

Checking the code, I can see you're splitting into two cases. I don't think we need those two cases because in every case, only the collection filter blocks can be added in inside Collection Filters, not variations of Collection Filters block.

samueljseay and others added 3 commits January 4, 2024 15:26
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
@samueljseay
Copy link
Contributor Author

samueljseay commented Jan 4, 2024

thanks @dinhtungdu I tested your changes and you're right I was overthinking the block filtering (I also learned that variations are not individual block types, neat!)

I've applied your suggestions and ready for re-review

Copy link
Member

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! This is LGTM now.

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
@samueljseay samueljseay merged commit faf1c6f into trunk Jan 4, 2024
24 of 26 checks passed
@samueljseay samueljseay deleted the dev/implement-inserter-behavior branch January 4, 2024 05:34
@github-actions github-actions bot added this to the 8.6.0 milestone Jan 4, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jan 4, 2024
@samueljseay samueljseay removed the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jan 4, 2024
@alopezari alopezari added the status: analysis complete Indicates if a PR has been analysed by Solaris label Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inserter behavior for collection filter blocks
3 participants