diff --git a/assets/js/blocks/rating-filter/block.tsx b/assets/js/blocks/rating-filter/block.tsx
index e90e97d22dd..76e9c4431b5 100644
--- a/assets/js/blocks/rating-filter/block.tsx
+++ b/assets/js/blocks/rating-filter/block.tsx
@@ -10,11 +10,13 @@ import {
} from '@woocommerce/base-context/hooks';
import { getSettingWithCoercion } from '@woocommerce/settings';
import { isBoolean, isObject, objectHasProp } from '@woocommerce/types';
+import FilterTitlePlaceholder from '@woocommerce/base-components/filter-placeholder';
import isShallowEqual from '@wordpress/is-shallow-equal';
import { useState, useCallback, useMemo, useEffect } from '@wordpress/element';
import CheckboxList from '@woocommerce/base-components/checkbox-list';
import { addQueryArgs, removeQueryArgs } from '@wordpress/url';
import { changeUrl } from '@woocommerce/utils';
+import classnames from 'classnames';
/**
* Internal dependencies
@@ -184,14 +186,28 @@ const RatingFilterBlock = ( {
[ productRatingsArray, setProductRatings ]
);
+ const heading = (
+
+ { blockAttributes.heading }
+
+ );
+
+ const filterHeading = isLoading ? (
+ { heading }
+ ) : (
+ heading
+ );
+
+ let orderedRatings = [];
+ let displayedOptions = [];
+
if (
! filteredCountsLoading &&
objectHasProp( filteredCounts, 'rating_counts' ) &&
Array.isArray( filteredCounts.rating_counts )
) {
- const orderedRatings = [ ...filteredCounts.rating_counts ].reverse();
-
- const displayedOptions = orderedRatings
+ orderedRatings = [ ...filteredCounts.rating_counts ].reverse();
+ displayedOptions = orderedRatings
.filter(
( item ) => isObject( item ) && Object.keys( item ).length > 0
)
@@ -214,30 +230,29 @@ const RatingFilterBlock = ( {
value: item?.rating?.toString(),
};
} );
-
- return (
- <>
- { ! isEditor && blockAttributes.heading && (
-
- { blockAttributes.heading }
-
- ) }
-
- {
- onClick( checked.toString() );
- } }
- isLoading={ isLoading }
- isDisabled={ isDisabled }
- />
-
- >
- );
}
- return null;
+
+ return (
+ <>
+ { ! isEditor && blockAttributes.heading && filterHeading }
+
+ {
+ onClick( checked.toString() );
+ } }
+ isLoading={ isLoading }
+ isDisabled={ isDisabled }
+ />
+
+ >
+ );
};
export default RatingFilterBlock;
diff --git a/assets/js/blocks/rating-filter/style.scss b/assets/js/blocks/rating-filter/style.scss
index f1987e6304e..5567e92a536 100644
--- a/assets/js/blocks/rating-filter/style.scss
+++ b/assets/js/blocks/rating-filter/style.scss
@@ -1,3 +1,12 @@
+.wc-block-rating-filter {
+ &.is-loading {
+ @include placeholder();
+ margin-top: $gap;
+ box-shadow: none;
+ border-radius: 0;
+ }
+}
+
.wp-block-woocommerce-rating-filter {
margin-bottom: $gap-large;