From 906b9a5be373698d8767ff9fa9816b4de3f14cb8 Mon Sep 17 00:00:00 2001
From: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
Date: Tue, 28 Nov 2023 08:33:31 +0100
Subject: [PATCH] Reorganise Columns controls and fix undefined problem in
Product Collection settings (#11937)
* Reorganise Columns controls and fix undefined problem in Product Collection settings
* Remove type condition in hasValue of Columns control
* Adjust the E2E tests locator to new changes
---
.../inspector-controls/columns-control.tsx | 45 ++++++++-----------
.../product-collection.page.ts | 2 +-
2 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/assets/js/blocks/product-collection/inspector-controls/columns-control.tsx b/assets/js/blocks/product-collection/inspector-controls/columns-control.tsx
index 80dc78ac4c3..0bdcbe2a31f 100644
--- a/assets/js/blocks/product-collection/inspector-controls/columns-control.tsx
+++ b/assets/js/blocks/product-collection/inspector-controls/columns-control.tsx
@@ -16,21 +16,13 @@ import {
import { DisplayLayoutToolbarProps } from '../types';
import { getDefaultDisplayLayout } from '../constants';
-const toggleLabel = __(
- 'Shrink columns to fit',
- 'woo-gutenberg-products-block'
-);
-
+const columnsLabel = __( 'Columns', 'woo-gutenberg-products-block' );
+const toggleLabel = __( 'Responsive', 'woo-gutenberg-products-block' );
const toggleHelp = __(
- 'Reduce the number of columns to better fit smaller screens and spaces.',
+ 'Automatically adjust the number of columns to better fit smaller screens.',
'woo-gutenberg-products-block'
);
-const getColumnsLabel = ( shrinkColumns: boolean ) =>
- shrinkColumns
- ? __( 'Max Columns', 'woo-gutenberg-products-block' )
- : __( 'Columns', 'woo-gutenberg-products-block' );
-
const ColumnsControl = ( props: DisplayLayoutToolbarProps ) => {
const { type, columns, shrinkColumns } = props.displayLayout;
const showColumnsControl = type === 'flex';
@@ -63,33 +55,32 @@ const ColumnsControl = ( props: DisplayLayoutToolbarProps ) => {
return showColumnsControl ? (
<>
- defaultLayout?.shrinkColumns !== shrinkColumns
- }
+ label={ columnsLabel }
+ hasValue={ () => defaultLayout?.columns !== columns }
isShownByDefault
onDeselect={ onPanelDeselect }
>
-
- defaultLayout?.columns !== columns ||
- defaultLayout?.type !== type
+ defaultLayout?.shrinkColumns !== shrinkColumns
}
isShownByDefault
onDeselect={ onPanelDeselect }
>
-
>
diff --git a/tests/e2e/tests/product-collection/product-collection.page.ts b/tests/e2e/tests/product-collection/product-collection.page.ts
index 3f407bb2390..9d7ab27981a 100644
--- a/tests/e2e/tests/product-collection/product-collection.page.ts
+++ b/tests/e2e/tests/product-collection/product-collection.page.ts
@@ -29,7 +29,7 @@ export const SELECTORS = {
onSaleControlLabel: 'Show only products on sale',
inheritQueryFromTemplateControl:
'.wc-block-product-collection__inherit-query-control',
- shrinkColumnsToFit: 'Shrink columns to fit',
+ shrinkColumnsToFit: 'Responsive',
productSearchLabel: 'Search',
productSearchButton: '.wp-block-search__button wp-element-button',
};