Commit 2607dd63628 for woocommerce

commit 2607dd6362855fc01f78dbdf1662ad2aa806d107
Author: Tung Du <dinhtungdu@gmail.com>
Date:   Thu Nov 26 11:03:51 2026 +0700

    Product Filters: add a Button style for the overlay's Filter products control (#71375)

    * Add a button style setting to the Product Filters overlay button

    Merchants can now pick Plain or Button for the "Filter products" button
    in the block settings. The setting shows only when the overlay is on
    (Mobile or Always).

    Plain is the default. Blocks with no stored style or an unknown style
    keep today's plain button, on the store and in the editor, and new
    blocks also start on Plain.

    Button adds the theme's button element class, so the button follows
    the theme's button styles from theme.json, the block's Button colors
    and any block style that styles buttons. It fills the width of the
    block on screens narrower than 480px, such as a phone.

    The plain button also gets a tap area of at least 24px with no visual change.

    Refs WOOPLUG-7823, #69084.

    Amp-Thread-ID: https://ampcode.com/threads/T-bae64071-6d1b-4ec7-bb55-ff3f2cceda3a
    Amp-Thread-ID: https://ampcode.com/threads/T-23679a20-4e37-4067-9c5b-b831a56c5490
    Co-authored-by: Amp <amp@ampcode.com>

    * Reword the Product Filters button style comments and changelog

    Comments and the changelog entry only; no code change.

    Amp-Thread-ID: https://ampcode.com/threads/T-23679a20-4e37-4067-9c5b-b831a56c5490
    Co-authored-by: Amp <amp@ampcode.com>

    * Simplify the Product Filters button style code

    Inline the PHP check, drop the PHP test and trim the comments.

    Amp-Thread-ID: https://ampcode.com/threads/T-23679a20-4e37-4067-9c5b-b831a56c5490
    Co-authored-by: Amp <amp@ampcode.com>

    * Keep the Product Filters Button at its natural width on phones

    The theme's button can be heavy at full width, so leave full width to
    themes, which can add it with a small block stylesheet.

    Amp-Thread-ID: https://ampcode.com/threads/T-23679a20-4e37-4067-9c5b-b831a56c5490
    Co-authored-by: Amp <amp@ampcode.com>

    * Remove the Product Filters button style unit test

    ---------

    Co-authored-by: Amp <amp@ampcode.com>

diff --git a/docs/block-development/reference/block-references.md b/docs/block-development/reference/block-references.md
index 4d337bd8830..98bafde1c93 100644
--- a/docs/block-development/reference/block-references.md
+++ b/docs/block-development/reference/block-references.md
@@ -1249,7 +1249,7 @@ Add a set of filters shoppers can use.
 - **Name:** woocommerce/product-filters
 - **Category:** woocommerce
 - **Supports:** align, color (background, button, heading, text, ~~enableContrastChecker~~), inserter, interactivity, layout (default, ~~allowEditing~~), position (sticky), spacing (blockGap), typography (fontSize)
-- **Attributes:** overlayMode, overlayPosition
+- **Attributes:** overlayButtonStyle, overlayMode, overlayPosition

 ## Active Filters - woocommerce/product-filter-active

diff --git a/plugins/woocommerce/changelog/69084-product-filters-overlay-button-style b/plugins/woocommerce/changelog/69084-product-filters-overlay-button-style
new file mode 100644
index 00000000000..662956d822e
--- /dev/null
+++ b/plugins/woocommerce/changelog/69084-product-filters-overlay-button-style
@@ -0,0 +1,4 @@
+Significance: minor
+Type: add
+
+Add a Button style setting so the Product Filters "Filter products" button can look like the theme's buttons.
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/block.json b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/block.json
index 174812809cb..bbf32b01233 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/block.json
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/block.json
@@ -53,6 +53,10 @@
 		"overlayPosition": {
 			"type": "string",
 			"enum": [ "left", "right" ]
+		},
+		"overlayButtonStyle": {
+			"type": "string",
+			"enum": [ "plain", "button" ]
 		}
 	},
 	"example": {},
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/edit.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/edit.tsx
index a001c9ed8ca..1422afb9240 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/edit.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/edit.tsx
@@ -30,6 +30,10 @@ import './editor.scss';
 import { type BlockAttributes } from './types';
 import { getColorsFromBlockSupports } from './utils/get-colors-from-block-supports';
 import { getOverlayMode, isOverlayMode } from './utils/overlay-mode';
+import {
+	getOverlayButtonStyle,
+	isOverlayButtonStyle,
+} from './utils/overlay-button-style';
 import { presetToCssVariable } from './utils/preset-to-css-variable';
 import { getDefaultAttributeId } from './inner-blocks/attribute-filter/utils';

@@ -66,6 +70,7 @@ export const Edit = ( props: BlockEditProps< BlockAttributes > ) => {
 	const hasOverlay = overlayMode !== 'off';
 	const overlayPosition =
 		attributes.overlayPosition === 'right' ? 'right' : 'left';
+	const overlayButtonStyle = getOverlayButtonStyle( attributes );
 	const [ isOpen, setIsOpen ] = useState( false );

 	const globalColors = getSetting< { background?: string; text?: string } >(
@@ -111,7 +116,10 @@ export const Edit = ( props: BlockEditProps< BlockAttributes > ) => {
 		filtersContent = (
 			<>
 				<button
-					className="wc-block-product-filters__open-overlay"
+					className={ clsx(
+						'wc-block-product-filters__open-overlay',
+						overlayButtonStyle === 'button' && 'wp-element-button'
+					) }
 					onClick={ () => setIsOpen( ! isOpen ) }
 				>
 					<Icon icon={ filterThreeLines } />
@@ -216,6 +224,31 @@ export const Edit = ( props: BlockEditProps< BlockAttributes > ) => {
 							/>
 						</ToggleGroupControl>
 					) }
+					{ overlayMode !== 'off' && (
+						<ToggleGroupControl
+							__nextHasNoMarginBottom
+							__next40pxDefaultSize
+							isBlock
+							label={ __( 'Button style', 'woocommerce' ) }
+							value={ overlayButtonStyle }
+							onChange={ ( value ) => {
+								if ( isOverlayButtonStyle( value ) ) {
+									setAttributes( {
+										overlayButtonStyle: value,
+									} );
+								}
+							} }
+						>
+							<ToggleGroupControlOption
+								value="plain"
+								label={ __( 'Plain', 'woocommerce' ) }
+							/>
+							<ToggleGroupControlOption
+								value="button"
+								label={ __( 'Button', 'woocommerce' ) }
+							/>
+						</ToggleGroupControl>
+					) }
 				</PanelBody>
 			</InspectorControls>
 			<div { ...blockProps }>{ filtersContent }</div>
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/style.scss b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/style.scss
index 0f15f069b68..516b86b444c 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/style.scss
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/style.scss
@@ -8,13 +8,8 @@

 	.wc-block-product-filters__open-overlay,
 	.wc-block-product-filters__close-overlay {
-		color: inherit;
-		background: transparent;
-		border: transparent;
 		display: flex;
 		align-items: center;
-		font-size: inherit;
-		padding: 0;
 		svg {
 			fill: currentColor;
 		}
@@ -23,10 +18,28 @@
 		}
 	}

+	.wc-block-product-filters__open-overlay:where(:not(.wp-element-button)),
+	.wc-block-product-filters__close-overlay {
+		color: inherit;
+		background: transparent;
+		border: transparent;
+		font-size: inherit;
+		padding: 0;
+	}
+
 	.wc-block-product-filters__open-overlay {
+		position: relative;
 		svg {
 			width: var(--wc-product-filters-overlay-icon-size, 1.5em);
 			height: var(--wc-product-filters-overlay-icon-size, 1.5em);
+			flex-shrink: 0;
+		}
+		// Tap area at least 24px tall.
+		&::after {
+			content: "";
+			position: absolute;
+			inset-inline: 0;
+			inset-block: min(0px, calc((100% - 24px) / 2));
 		}
 	}

diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/types.ts b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/types.ts
index ea1f6b2bd56..b30fa6c9ac3 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/types.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/types.ts
@@ -56,10 +56,13 @@ export type ProductFiltersContext = {
 // ----------------------------------------
 export type OverlayMode = 'off' | 'mobile' | 'always';

+export type OverlayButtonStyle = 'plain' | 'button';
+
 export type BlockAttributes = {
 	productId?: string;
 	overlayMode?: OverlayMode;
 	overlayPosition?: 'left' | 'right';
+	overlayButtonStyle?: OverlayButtonStyle;
 };

 export type EditProps = BlockEditProps< BlockAttributes >;
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/utils/overlay-button-style.ts b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/utils/overlay-button-style.ts
new file mode 100644
index 00000000000..628b7b5c841
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/utils/overlay-button-style.ts
@@ -0,0 +1,21 @@
+/**
+ * Internal dependencies
+ */
+import type { BlockAttributes, OverlayButtonStyle } from '../types';
+
+const OVERLAY_BUTTON_STYLES: readonly OverlayButtonStyle[] = [
+	'plain',
+	'button',
+];
+
+export const isOverlayButtonStyle = (
+	value: unknown
+): value is OverlayButtonStyle =>
+	OVERLAY_BUTTON_STYLES.includes( value as OverlayButtonStyle );
+
+export const getOverlayButtonStyle = (
+	attributes: BlockAttributes
+): OverlayButtonStyle =>
+	isOverlayButtonStyle( attributes.overlayButtonStyle )
+		? attributes.overlayButtonStyle
+		: 'plain';
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilters.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilters.php
index b90f7e94404..6c815b694bc 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilters.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductFilters.php
@@ -234,6 +234,11 @@ CSS;
 		$overlay_mode     = $this->get_overlay_mode( $attributes );
 		$has_overlay      = 'off' !== $overlay_mode;
 		$overlay_position = isset( $attributes['overlayPosition'] ) && 'right' === $attributes['overlayPosition'] ? 'right' : 'left';
+		$is_button_style  = isset( $attributes['overlayButtonStyle'] ) && 'button' === $attributes['overlayButtonStyle'];
+		$button_classes   = array( 'wc-block-product-filters__open-overlay' );
+		if ( $is_button_style ) {
+			$button_classes[] = wp_theme_get_element_class_name( 'button' );
+		}

 		$state               = wp_interactivity_state( 'woocommerce/product-filters' );
 		$filter_empty_states = $state['filterEmptyStates'][ $product_filters_key ] ?? array();
@@ -272,7 +277,7 @@ CSS;
 			<?php if ( $has_overlay ) : ?>
 				<button
 					type="button"
-					class="wc-block-product-filters__open-overlay"
+					class="<?php echo esc_attr( implode( ' ', $button_classes ) ); ?>"
 					data-wp-init="callbacks.initOverlay"
 					data-wp-on--click="actions.openOverlay"
 				>