-
- { hasValidConstraints && (
-
- ) }
-
-
- { showInputFields && (
- <>
+ setMaxPriceInput( value );
+ } }
+ onBlur={ priceInputOnBlur }
+ disabled={ isLoading || ! hasValidConstraints }
+ value={ maxPriceInput }
+ />
+
+ ) }
+
+ { ! showInputFields &&
+ ! isLoading &&
+ Number.isFinite( minPrice ) &&
+ Number.isFinite( maxPrice ) && (
+
{
- if ( value === minPriceInput ) {
- return;
- }
- setMinPriceInput( value );
- } }
- onBlur={ priceInputOnBlur }
- disabled={ isLoading || ! hasValidConstraints }
- value={ minPriceInput }
+ value={ minPrice }
/>
{
- if ( value === maxPriceInput ) {
- return;
- }
- setMaxPriceInput( value );
- } }
- onBlur={ priceInputOnBlur }
- disabled={ isLoading || ! hasValidConstraints }
- value={ maxPriceInput }
+ value={ maxPrice }
/>
- >
+
+ ) }
+
+ { ( minPrice !== minConstraint ||
+ maxPrice !== maxConstraint ) && (
+
{
+ onChange( [ minConstraint, maxConstraint ] );
+ debouncedUpdateQuery();
+ } }
+ screenReaderLabel={ __(
+ 'Reset price filter',
+ 'woo-gutenberg-products-block'
+ ) }
+ />
) }
- { ! showInputFields &&
- ! isLoading &&
- Number.isFinite( minPrice ) &&
- Number.isFinite( maxPrice ) && (
-
- { __( 'Price', 'woo-gutenberg-products-block' ) }
- :
-
- –
-
-
- ) }
{ showFilterButton && (
onSubmit( minPrice, maxPrice ) }
diff --git a/assets/js/blocks/price-filter/edit.tsx b/assets/js/blocks/price-filter/edit.tsx
index df830023625..4e2fbbb7187 100644
--- a/assets/js/blocks/price-filter/edit.tsx
+++ b/assets/js/blocks/price-filter/edit.tsx
@@ -32,8 +32,13 @@ export default function ( {
attributes,
setAttributes,
}: BlockEditProps< Attributes > ) {
- const { heading, headingLevel, showInputFields, showFilterButton } =
- attributes;
+ const {
+ heading,
+ headingLevel,
+ showInputFields,
+ inlineInput,
+ showFilterButton,
+ } = attributes;
const blockProps = useBlockProps();
@@ -41,14 +46,11 @@ export default function ( {
return (
+ { showInputFields && (
+
+ setAttributes( {
+ inlineInput: ! inlineInput,
+ } )
+ }
+ help={ __(
+ 'Show input fields inline with the slider.',
+ 'woo-gutenberg-products-block'
+ ) }
+ />
+ ) }
}
- label={ __(
- 'Filter Products by Price',
- 'woo-gutenberg-products-block'
- ) }
+ label={ __( 'Filter by Price', 'woo-gutenberg-products-block' ) }
instructions={ __(
'Display a slider to filter products in your store by price.',
'woo-gutenberg-products-block'
diff --git a/assets/js/blocks/price-filter/editor.scss b/assets/js/blocks/price-filter/editor.scss
index 44c62d27dea..238b9cd7404 100644
--- a/assets/js/blocks/price-filter/editor.scss
+++ b/assets/js/blocks/price-filter/editor.scss
@@ -15,6 +15,19 @@
}
}
+.wc-block-price-filter__price-range-toggle {
+ width: 100%;
+
+ > div {
+ flex-grow: 1;
+ }
+}
+
+.components-base-control__label {
+ text-transform: uppercase;
+ @include font-size(small);
+}
+
.wc-block-price-slider {
.components-placeholder__instructions {
border-bottom: 1px solid #e0e2e6;
diff --git a/assets/js/blocks/price-filter/frontend.ts b/assets/js/blocks/price-filter/frontend.ts
index ac4e2badb83..6d38ed17078 100644
--- a/assets/js/blocks/price-filter/frontend.ts
+++ b/assets/js/blocks/price-filter/frontend.ts
@@ -14,6 +14,7 @@ const getProps = ( el: HTMLElement ) => {
return {
attributes: {
showInputFields: el.dataset.showinputfields === 'true',
+ inlineInput: el.dataset.inlineInput !== 'false',
showFilterButton: el.dataset.showfilterbutton === 'true',
heading: el.dataset.heading || blockAttributes.heading.default,
headingLevel: el.dataset.headingLevel
diff --git a/assets/js/blocks/price-filter/index.tsx b/assets/js/blocks/price-filter/index.tsx
index 407c62b3d13..b8e5ded64db 100644
--- a/assets/js/blocks/price-filter/index.tsx
+++ b/assets/js/blocks/price-filter/index.tsx
@@ -5,7 +5,6 @@ import { __ } from '@wordpress/i18n';
import { createBlock, registerBlockType } from '@wordpress/blocks';
import classNames from 'classnames';
import { Icon, currencyDollar } from '@wordpress/icons';
-import { isFeaturePluginBuild } from '@woocommerce/block-settings';
import { useBlockProps } from '@wordpress/block-editor';
/**
@@ -16,9 +15,9 @@ import metadata from './block.json';
import { blockAttributes } from './attributes';
registerBlockType( metadata, {
- title: __( 'Filter Products by Price', 'woo-gutenberg-products-block' ),
+ title: __( 'Filter by Price', 'woo-gutenberg-products-block' ),
description: __(
- 'Allow customers to filter the products by choosing a lower or upper price limit. Works in combination with the All Products block.',
+ 'Allow customers to filter products by price range.',
'woo-gutenberg-products-block'
),
icon: {
@@ -29,16 +28,6 @@ registerBlockType( metadata, {
/>
),
},
- supports: {
- ...metadata.supports,
- ...( isFeaturePluginBuild() && {
- __experimentalBorder: {
- radius: true,
- color: true,
- width: false,
- },
- } ),
- },
attributes: {
...metadata.attributes,
...blockAttributes,
@@ -62,6 +51,7 @@ registerBlockType( metadata, {
'woo-gutenberg-products-block'
),
headingLevel: 3,
+ inlineInput: true,
} ),
},
],
diff --git a/assets/js/blocks/price-filter/style.scss b/assets/js/blocks/price-filter/style.scss
index daf012103e1..03784801a34 100644
--- a/assets/js/blocks/price-filter/style.scss
+++ b/assets/js/blocks/price-filter/style.scss
@@ -1,4 +1,6 @@
.wp-block-woocommerce-price-filter {
+ border-color: $gray-700;
+ border-radius: 4px;
border-style: none !important;
}
@@ -17,6 +19,7 @@
border-radius: inherit;
border-color: inherit;
+ // Force inherting style is required for global style.
input {
border-radius: inherit !important;
border-color: inherit !important;
diff --git a/assets/js/blocks/price-filter/types.ts b/assets/js/blocks/price-filter/types.ts
index 429c298998c..bb574ff6638 100644
--- a/assets/js/blocks/price-filter/types.ts
+++ b/assets/js/blocks/price-filter/types.ts
@@ -1,6 +1,7 @@
export interface Attributes {
showFilterButton: boolean;
showInputFields: boolean;
+ inlineInput: boolean;
heading: string;
headingLevel: number;
className?: string;
diff --git a/assets/js/blocks/stock-filter/test/__snapshots__/block.js.snap b/assets/js/blocks/stock-filter/test/__snapshots__/block.js.snap
index 8f24b78b474..cff704e558c 100644
--- a/assets/js/blocks/stock-filter/test/__snapshots__/block.js.snap
+++ b/assets/js/blocks/stock-filter/test/__snapshots__/block.js.snap
@@ -95,13 +95,13 @@ exports[`Testing stock filter renders the stock filter block with the filter but