-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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] Render headings as inner blocks of collection filters #43109
[Experimental] Render headings as inner blocks of collection filters #43109
Conversation
Test Results SummaryCommit SHA: cb24302
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. |
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for Price Filter it should pretty much always render unless something has gone wrong. (I might not have considered edge cases here, please enlighten me if I have missed some).
There is also a case when there is only one simple product, the min and max price is equal, the Price filter shouldn't be render at that point. (I fixed that in https://github.com/woocommerce/woocommerce/pull/43112/files#diff-cae9a0f3ce62ffc67ce67010b5f92334df81848c280613e5f49c43d6819b3591R147-R152).
In my test site I just manually delete them all
Theoretically, rating can be tested with a filtered query that returns products without rating, but it doesn't work now with Store API. #42811 will fix that issue.
.../woocommerce-blocks/assets/js/blocks/collection-filters/inner-blocks/rating-filter/index.tsx
Outdated
Show resolved
Hide resolved
plugins/woocommerce-blocks/assets/js/blocks/collection-filters/edit.tsx
Outdated
Show resolved
Hide resolved
@@ -38,7 +43,6 @@ import { AttributeDropdown } from './components/attribute-dropdown'; | |||
import './style.scss'; | |||
import { extractBuiltInColor } from '../../utils'; | |||
import { useStyleProps } from '../../../../base/hooks'; | |||
import styled from '@emotion/styled'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import leftover in the branch this branches from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
const template: Template[] = [ | ||
[ | ||
'core/heading', | ||
{ content: __( 'Filter by Stock Status', 'woocommerce' ) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The level is missing here.
be7b261
into
dev/dropdown-support-text-color
Changes proposed in this Pull Request:
We needed to achieve not displaying filter headings when there is nothing to filter. For example when there are no product ratings it makes no sense to render the "Filter by rating" header on its own since nothing can be filtered.
To do this, this PR adjusts all the new experimental filter blocks to accept only core/heading as an inner block. With this change we can render the inner blocks on PHP side, but if we don't have any data (e.g. no product ratings) we can simply not render the whole block including inner blocks.
This also adjusts the collection filters template that auto inserts all the filter blocks. It now inserts the headings as child blocks.
Closes #42055
How to test the changes in this Pull Request:
You can firstly insert the new collection filters block in the editor. You should see that inner heading blocks are inserted. You can test that it saves by updating / saving and then reload the page to ensure the inner heading blocks are retained.
Each block has different conditions in which it will not render. Rating can be tested for example, by ensuring you have no product reviews. (In my test site I just manually delete them all). Once this is done, view the frontend page corresponding to your collection filters and see that nothing is rendered for the rating filter.
for Price Filter it should pretty much always render unless something has gone wrong. (I might not have considered edge cases here, please enlighten me if I have missed some).
for Stock Status filter TBD
for active filters, nothing should render unless at least one filter is active on the page. e.g. with no query params on the page the heading should not render. If you choose a single filter like price range, the heading should render along with the active filter.
Changelog entry
Significance
Type
Message
Comment
Hide block headings when there are no filter options for experimental collection filter blocks.