Commit ff60dda3b3 for woocommerce
commit ff60dda3b3d116369b4fa4c7e348fb98c47c7212
Author: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
Date: Wed Sep 17 14:56:37 2025 +0200
Remove unnecessary attribute from Stock Indicator (#60909)
* Remove isDescendentOfQueryLoop attribute from Stock Indicator block
* Add changelog
* Remove useEffect
diff --git a/plugins/woocommerce/changelog/remove-unnecessary-attribute-from-stock-indicator b/plugins/woocommerce/changelog/remove-unnecessary-attribute-from-stock-indicator
new file mode 100644
index 0000000000..7b690ab339
--- /dev/null
+++ b/plugins/woocommerce/changelog/remove-unnecessary-attribute-from-stock-indicator
@@ -0,0 +1,4 @@
+Significance: patch
+Type: tweak
+
+Stock Indicator: remove unused attribute
diff --git a/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/block.json b/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/block.json
index ab77852046..debb3e6dfe 100644
--- a/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/block.json
+++ b/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/block.json
@@ -5,10 +5,6 @@
"description": "Let shoppers know when products are out of stock or on backorder. This block is hidden when products are in stock.",
"category": "woocommerce-product-elements",
"attributes": {
- "isDescendentOfQueryLoop": {
- "type": "boolean",
- "default": false
- },
"isDescendantOfAllProducts": {
"type": "boolean",
"default": false
diff --git a/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/edit.tsx b/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/edit.tsx
index 455f1fd7d6..1ce3f2f938 100644
--- a/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/edit.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/edit.tsx
@@ -5,7 +5,6 @@ import EditProductLink from '@woocommerce/editor-components/edit-product-link';
import { useBlockProps } from '@wordpress/block-editor';
import type { BlockEditProps } from '@wordpress/blocks';
import { ProductQueryContext as Context } from '@woocommerce/blocks/product-query/types';
-import { useEffect } from '@wordpress/element';
/**
* Internal dependencies
@@ -15,7 +14,6 @@ import type { BlockAttributes } from './types';
const Edit = ( {
attributes,
- setAttributes,
context,
}: BlockEditProps< BlockAttributes > & { context: Context } ): JSX.Element => {
const { style, ...blockProps } = useBlockProps( {
@@ -26,12 +24,6 @@ const Edit = ( {
...attributes,
...context,
};
- const isDescendentOfQueryLoop = Number.isFinite( context.queryId );
-
- useEffect(
- () => setAttributes( { isDescendentOfQueryLoop } ),
- [ setAttributes, isDescendentOfQueryLoop ]
- );
return (
<div
diff --git a/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/test/block.test.tsx b/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/test/block.test.tsx
index 8a6b4ee7b9..5b097335bd 100644
--- a/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/test/block.test.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/test/block.test.tsx
@@ -192,10 +192,7 @@ describe( 'Stock Indicator Block', () => {
const { container } = render(
<ProductDataContextProvider product={ product } isLoading={ false }>
- <Block
- isDescendentOfQueryLoop={ false }
- isDescendantOfAllProducts={ false }
- />
+ <Block isDescendantOfAllProducts={ false } />
</ProductDataContextProvider>
);
@@ -214,10 +211,7 @@ describe( 'Stock Indicator Block', () => {
const { container } = render(
<ProductDataContextProvider product={ product } isLoading={ false }>
- <Block
- isDescendentOfQueryLoop={ false }
- isDescendantOfAllProducts={ false }
- />
+ <Block isDescendantOfAllProducts={ false } />
</ProductDataContextProvider>
);
@@ -236,10 +230,7 @@ describe( 'Stock Indicator Block', () => {
const { container } = render(
<ProductDataContextProvider product={ product } isLoading={ false }>
- <Block
- isDescendentOfQueryLoop={ false }
- isDescendantOfAllProducts={ false }
- />
+ <Block isDescendantOfAllProducts={ false } />
</ProductDataContextProvider>
);
@@ -256,10 +247,7 @@ describe( 'Stock Indicator Block', () => {
const { container } = render(
<ProductDataContextProvider product={ product } isLoading={ false }>
- <Block
- isDescendentOfQueryLoop={ false }
- isDescendantOfAllProducts={ false }
- />
+ <Block isDescendantOfAllProducts={ false } />
</ProductDataContextProvider>
);
diff --git a/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/types.ts b/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/types.ts
index ce94a32cf2..65102cf284 100644
--- a/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/types.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/atomic/blocks/product-elements/stock-indicator/types.ts
@@ -1,4 +1,3 @@
export interface BlockAttributes {
- isDescendentOfQueryLoop: boolean;
isDescendantOfAllProducts: boolean;
}