From 59f2ba9da21a672cbe3f87e7bbfcb10758dd5161 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Wed, 5 Jul 2023 08:51:02 +0200 Subject: [PATCH] Fix filter count display toggle (#10096) * fix save method * improve check * Only display counts if showCounts is true --------- Co-authored-by: Alexandre Lara --- assets/js/blocks/attribute-filter/index.tsx | 7 +------ assets/js/blocks/attribute-filter/utils.ts | 2 +- assets/js/blocks/rating-filter/index.tsx | 7 +------ assets/js/blocks/rating-filter/utils.ts | 2 +- assets/js/blocks/stock-filter/index.tsx | 7 +------ assets/js/blocks/stock-filter/utils.ts | 2 +- 6 files changed, 6 insertions(+), 21 deletions(-) diff --git a/assets/js/blocks/attribute-filter/index.tsx b/assets/js/blocks/attribute-filter/index.tsx index e66cdeb069d..f1e63575ff0 100644 --- a/assets/js/blocks/attribute-filter/index.tsx +++ b/assets/js/blocks/attribute-filter/index.tsx @@ -49,12 +49,7 @@ registerBlockType( metadata, { { ...useBlockProps.save( { className: classNames( 'is-loading', className ), } ) } - > - - + /> ); }, deprecated, diff --git a/assets/js/blocks/attribute-filter/utils.ts b/assets/js/blocks/attribute-filter/utils.ts index 2463243742e..f76609a4f58 100644 --- a/assets/js/blocks/attribute-filter/utils.ts +++ b/assets/js/blocks/attribute-filter/utils.ts @@ -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, diff --git a/assets/js/blocks/rating-filter/index.tsx b/assets/js/blocks/rating-filter/index.tsx index 21c053dd5ef..35319dea5ef 100644 --- a/assets/js/blocks/rating-filter/index.tsx +++ b/assets/js/blocks/rating-filter/index.tsx @@ -36,12 +36,7 @@ registerBlockType( metadata, { { ...useBlockProps.save( { className: classNames( 'is-loading', className ), } ) } - > - - + /> ); }, deprecated, diff --git a/assets/js/blocks/rating-filter/utils.ts b/assets/js/blocks/rating-filter/utils.ts index 5b5209993f7..a6ba5a02ba6 100644 --- a/assets/js/blocks/rating-filter/utils.ts +++ b/assets/js/blocks/rating-filter/utils.ts @@ -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 ) || diff --git a/assets/js/blocks/stock-filter/index.tsx b/assets/js/blocks/stock-filter/index.tsx index e887e7cdb58..3c610e511e5 100644 --- a/assets/js/blocks/stock-filter/index.tsx +++ b/assets/js/blocks/stock-filter/index.tsx @@ -38,12 +38,7 @@ registerBlockType( metadata, { { ...useBlockProps.save( { className: classNames( 'is-loading', className ), } ) } - > - - + /> ); }, deprecated, diff --git a/assets/js/blocks/stock-filter/utils.ts b/assets/js/blocks/stock-filter/utils.ts index d692e459316..3addadffd3c 100644 --- a/assets/js/blocks/stock-filter/utils.ts +++ b/assets/js/blocks/stock-filter/utils.ts @@ -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 ) ||