Commit 9d0f02cafe9 for woocommerce
commit 9d0f02cafe935907cd8eaf2ffb9a5bd87fe7a728
Author: Luigi Teschio <gigitux@gmail.com>
Date: Thu May 21 10:17:46 2026 +0200
Fix products app drawer close query state (#65224)
diff --git a/packages/js/experimental-products-app/changelog/fix-products-app-drawer-close-query b/packages/js/experimental-products-app/changelog/fix-products-app-drawer-close-query
new file mode 100644
index 00000000000..7d8432a2e8e
--- /dev/null
+++ b/packages/js/experimental-products-app/changelog/fix-products-app-drawer-close-query
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Ensure the experimental products app quick edit drawer closes when using the close icon or Cancel button.
diff --git a/packages/js/experimental-products-app/src/dataviews-actions/actions.tsx b/packages/js/experimental-products-app/src/dataviews-actions/actions.tsx
index dd7a24cb5ea..c301ceec29a 100644
--- a/packages/js/experimental-products-app/src/dataviews-actions/actions.tsx
+++ b/packages/js/experimental-products-app/src/dataviews-actions/actions.tsx
@@ -73,11 +73,10 @@ function getSelectionPath(
{} as Record< string, string >
);
- delete nextQuery.quickEdit;
-
return getProductListNavigationPath( path, {
...nextQuery,
postId: productIds.join( ',' ),
+ quickEdit: undefined,
} );
}
diff --git a/packages/js/experimental-products-app/src/product-edit/index.tsx b/packages/js/experimental-products-app/src/product-edit/index.tsx
index 7653f531e3e..87cb5bbabe4 100644
--- a/packages/js/experimental-products-app/src/product-edit/index.tsx
+++ b/packages/js/experimental-products-app/src/product-edit/index.tsx
@@ -669,7 +669,8 @@ export default function ProductEdit( { products, isOpen }: ProductEditProps ) {
);
const nextQuery = {
...query,
- } as Record< string, string >;
+ quickEdit: undefined,
+ } as Record< string, string | undefined >;
editedProductIds.forEach( ( productId ) => {
clearEntityRecordEdits( 'root', 'product', productId );
@@ -677,8 +678,6 @@ export default function ProductEdit( { products, isOpen }: ProductEditProps ) {
setBulkEditData( {} as ProductBulkEditFormData );
- delete nextQuery.quickEdit;
-
navigate( getProductListNavigationPath( path, nextQuery ) );
}, [ clearEntityRecordEdits, navigate, path, query, selectedProducts ] );
diff --git a/packages/js/experimental-products-app/src/product-list/index.tsx b/packages/js/experimental-products-app/src/product-list/index.tsx
index faf6031f230..1a060c51fb1 100644
--- a/packages/js/experimental-products-app/src/product-list/index.tsx
+++ b/packages/js/experimental-products-app/src/product-list/index.tsx
@@ -98,7 +98,7 @@ export default function ProductList( {
if ( items.length > 0 ) {
nextParams.postId = items.join( ',' );
} else {
- delete nextParams.postId;
+ nextParams.postId = undefined;
}
navigate(
@@ -126,10 +126,9 @@ export default function ProductList( {
const nextParams = {
...currentQuery,
activeView: nextTab,
+ postId: undefined,
};
- delete nextParams.postId;
-
navigate(
getProductListNavigationPath( location.path, nextParams )
);
diff --git a/packages/js/experimental-products-app/src/product-list/utils.test.ts b/packages/js/experimental-products-app/src/product-list/utils.test.ts
index a75e665018e..c9643ecc516 100644
--- a/packages/js/experimental-products-app/src/product-list/utils.test.ts
+++ b/packages/js/experimental-products-app/src/product-list/utils.test.ts
@@ -53,6 +53,18 @@ describe( 'product list utils', () => {
'woocommerce-products-dashboard?post_type=product&activeView=draft'
);
} );
+
+ it( 'removes existing query args when a param is set to undefined', () => {
+ expect(
+ getProductListNavigationPath(
+ 'woocommerce-products-dashboard?post_type=product&postId=12&quickEdit=true',
+ {
+ postId: undefined,
+ quickEdit: undefined,
+ }
+ )
+ ).toBe( 'woocommerce-products-dashboard?post_type=product' );
+ } );
} );
describe( 'getProductsWithEmbeddedVariations', () => {
diff --git a/packages/js/experimental-products-app/src/variation-view/index.tsx b/packages/js/experimental-products-app/src/variation-view/index.tsx
index f98a48785cd..5927f307caf 100644
--- a/packages/js/experimental-products-app/src/variation-view/index.tsx
+++ b/packages/js/experimental-products-app/src/variation-view/index.tsx
@@ -182,7 +182,7 @@ export function VariationView( { productId }: VariationViewProps ) {
if ( items.length > 0 ) {
nextQuery.postId = items.join( ',' );
} else {
- delete nextQuery.postId;
+ nextQuery.postId = undefined;
}
navigate(