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

Commit

Permalink
Fix filter count display toggle (#10096)
Browse files Browse the repository at this point in the history
* fix save method

* improve check

* Only display counts if showCounts is true

---------

Co-authored-by: Alexandre Lara <[email protected]>
  • Loading branch information
gigitux and thealexandrelara authored Jul 5, 2023
1 parent c389cb7 commit 59f2ba9
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 21 deletions.
7 changes: 1 addition & 6 deletions assets/js/blocks/attribute-filter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,7 @@ registerBlockType( metadata, {
{ ...useBlockProps.save( {
className: classNames( 'is-loading', className ),
} ) }
>
<span
aria-hidden
className="wc-block-product-attribute-filter__placeholder"
/>
</div>
/>
);
},
deprecated,
Expand Down
2 changes: 1 addition & 1 deletion assets/js/blocks/attribute-filter/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const parseAttributes = ( data: Record< string, unknown > ) => {
isString( data?.attributeId ) ? data.attributeId : '0',
10
),
showCounts: data?.showCounts !== 'false',
showCounts: data?.showCounts === 'true',
queryType:
( isString( data?.queryType ) && data.queryType ) ||
metadata.attributes.queryType.default,
Expand Down
7 changes: 1 addition & 6 deletions assets/js/blocks/rating-filter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ registerBlockType( metadata, {
{ ...useBlockProps.save( {
className: classNames( 'is-loading', className ),
} ) }
>
<span
aria-hidden
className="wc-block-product-rating-filter__placeholder"
/>
</div>
/>
);
},
deprecated,
Expand Down
2 changes: 1 addition & 1 deletion assets/js/blocks/rating-filter/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const formatSlug = ( slug: string ) =>
export const parseAttributes = ( data: Record< string, unknown > ) => {
return {
showFilterButton: data?.showFilterButton === 'true',
showCounts: data?.showCounts !== 'false',
showCounts: data?.showCounts === 'true',
isPreview: false,
displayStyle:
( isString( data?.displayStyle ) && data.displayStyle ) ||
Expand Down
7 changes: 1 addition & 6 deletions assets/js/blocks/stock-filter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ registerBlockType( metadata, {
{ ...useBlockProps.save( {
className: classNames( 'is-loading', className ),
} ) }
>
<span
aria-hidden
className="wc-block-product-stock-filter__placeholder"
/>
</div>
/>
);
},
deprecated,
Expand Down
2 changes: 1 addition & 1 deletion assets/js/blocks/stock-filter/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const parseAttributes = ( data: Record< string, unknown > ) => {
parseInt( data.headingLevel, 10 ) ) ||
metadata.attributes.headingLevel.default,
showFilterButton: data?.showFilterButton === 'true',
showCounts: data?.showCounts !== 'false',
showCounts: data?.showCounts === 'true',
isPreview: false,
displayStyle:
( isString( data?.displayStyle ) && data.displayStyle ) ||
Expand Down

0 comments on commit 59f2ba9

Please sign in to comment.