diff --git a/plugins/woocommerce-blocks/assets/js/blocks/product-categories/frontend.js b/plugins/woocommerce-blocks/assets/js/blocks/product-categories/frontend.js
index 1974f7fc8f2..dbb7c073ebd 100644
--- a/plugins/woocommerce-blocks/assets/js/blocks/product-categories/frontend.js
+++ b/plugins/woocommerce-blocks/assets/js/blocks/product-categories/frontend.js
@@ -22,6 +22,7 @@ if ( containers.length ) {
isDropdown: data.isDropdown === 'true',
isHierarchical: data.isHierarchical === 'true',
};
+ el.classList.remove( 'is-loading' );
render( , el );
} );
diff --git a/plugins/woocommerce-blocks/assets/js/blocks/product-categories/index.js b/plugins/woocommerce-blocks/assets/js/blocks/product-categories/index.js
index 8375cb87cab..804af8fd193 100644
--- a/plugins/woocommerce-blocks/assets/js/blocks/product-categories/index.js
+++ b/plugins/woocommerce-blocks/assets/js/blocks/product-categories/index.js
@@ -81,19 +81,31 @@ registerBlockType( 'woocommerce/product-categories', {
*/
save( { attributes } ) {
const { hasCount, hasEmpty, isDropdown, isHierarchical } = attributes;
- const props = {};
+ const data = {};
if ( hasCount ) {
- props[ 'data-has-count' ] = true;
+ data[ 'data-has-count' ] = true;
}
if ( hasEmpty ) {
- props[ 'data-has-empty' ] = true;
+ data[ 'data-has-empty' ] = true;
}
if ( isDropdown ) {
- props[ 'data-is-dropdown' ] = true;
+ data[ 'data-is-dropdown' ] = true;
}
if ( isHierarchical ) {
- props[ 'data-is-hierarchical' ] = true;
+ data[ 'data-is-hierarchical' ] = true;
}
- return
LOADING
;
+ return (
+
+ { isDropdown ? (
+
+ ) : (
+
+ ) }
+
+ );
},
} );
diff --git a/plugins/woocommerce-blocks/assets/js/blocks/product-categories/style.scss b/plugins/woocommerce-blocks/assets/js/blocks/product-categories/style.scss
index 1ceb684cd5c..7eef69d06e9 100644
--- a/plugins/woocommerce-blocks/assets/js/blocks/product-categories/style.scss
+++ b/plugins/woocommerce-blocks/assets/js/blocks/product-categories/style.scss
@@ -9,3 +9,12 @@
margin-right: 0.5em;
}
}
+
+.wp-block-woocommerce-product-categories.is-loading .wc-block-product-categories__placeholder {
+ display: inline-block;
+ height: 1em;
+ width: 50%;
+ min-width: 200px;
+ background: currentColor;
+ opacity: 0.2;
+}