Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Price Filter: Introduce view block #11191

Closed
wants to merge 80 commits into from

Conversation

dinhtungdu
Copy link
Member

@dinhtungdu dinhtungdu commented Oct 10, 2023

What

  • This PR closes two issue as the same time (#11306 and New Price Filter block powered by Interactivity API #10813) because the Price Filter block was used for experimenting new block structure.
  • This PR introduces a new term called view block. This isn't a Gutenberg or WooCommerce term. With the block structure introduced in this PR, filter blocks don't need to fetch and process the data from Store API themselves, instead they just need to consume the data passed through context, that's why I called them view blocks. See Block structure for extensibility woocommerce#42178 for more detail.
  • Move the logic calculating and enqueuing Interactivity Store to the Collection Filters block.
  • The store data is passed to inner filter blocks through a context named filterData.
  • Inner filter blocks (the Collection Price Filter in this case) consume that context to build the view. 
  • View blocks must declare an attribute named filterType with a default value set to one of these strings to indicate their type: priceattribute , stock , or rating. Collection Filters block uses this attribute to build the filter data.
  • View blocks can have their own data:
    • State: rangeStyle  in this case.
    • Attributes: showInputFieldsinlineInput.

Fixes woocommerce/woocommerce#42178 #10813

Why

By delegating the data fetching and processing to the Collection Filters block, we

  • simplify the filter block code and logic.
  • reducing the duplication between filter blocks.

Testing Instructions

Please consider any edge cases this change may have, and also other areas of the product this may impact.

  1. Add Product Collection > Collection Filters > Collection Price Filters to a new page.
  2. See the block work in the editor preview and on the front end.
  • Do not include in the Testing Notes
  • Should be tested by the development team exclusively.

WooCommerce Visibility

Required:

  • WooCommerce Core
  • Feature plugin
  • Experimental
  • N/A

Checklist

Required:

  • This PR has either a[type] label or a [skip-changelog] label.
  • This PR is assigned to a milestone.

Conditional:

  • This PR has a changelog description (if[skip-changelog] label is not present).
  • This PR adds/removes a feature flag & I've updatedthis doc.
  • This PR adds/removes an experimental interfaces, and I've updatedthis doc.
  • This PR has been accessibility tested.
  • This PR has had any necessary documentation added/updated.

Changelog

N/a

@dinhtungdu dinhtungdu changed the base branch from try/inner-filter-block to trunk October 14, 2023 12:56
@dinhtungdu dinhtungdu self-assigned this Oct 20, 2023
@dinhtungdu dinhtungdu added status: needs review type: enhancement The issue is a request for an enhancement. block: filter by price Issues related to the Filter by Price block. skip-changelog PRs that you don't want to appear in the changelog. labels Oct 20, 2023
@dinhtungdu dinhtungdu marked this pull request as ready for review October 20, 2023 08:13
@woocommercebot woocommercebot requested a review from a team October 20, 2023 08:13
@dinhtungdu dinhtungdu changed the title Try: filter block as view block Introduce filter view block Oct 20, 2023
@dinhtungdu dinhtungdu changed the title Introduce filter view block Frontend Filters: Introduce view block Oct 20, 2023
@dinhtungdu dinhtungdu changed the title Frontend Filters: Introduce view block Price Filter: Introduce view block Oct 20, 2023
@dinhtungdu
Copy link
Member Author

Closing in favor of woocommerce/woocommerce#42178

@dinhtungdu dinhtungdu closed this Oct 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: filter by price Issues related to the Filter by Price block. skip-changelog PRs that you don't want to appear in the changelog. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block structure for extensibility
3 participants