Add reset button to all filter blocks (https://github.com/woocommerce/woocommerce-blocks/pull/8366)
This commit is contained in:
parent
e0c4052bfa
commit
0a6daae35f
|
@ -77,6 +77,10 @@ export interface PriceSliderProps {
|
|||
* What step values the slider uses.
|
||||
*/
|
||||
step?: number;
|
||||
/**
|
||||
* Wheter we're in the editor or not.
|
||||
*/
|
||||
isEditor?: boolean;
|
||||
}
|
||||
|
||||
const PriceSlider = ( {
|
||||
|
@ -92,6 +96,7 @@ const PriceSlider = ( {
|
|||
inlineInput = true,
|
||||
isLoading = false,
|
||||
isUpdating = false,
|
||||
isEditor = false,
|
||||
onSubmit = () => void 0,
|
||||
}: PriceSliderProps ): JSX.Element => {
|
||||
const minRange = useRef< HTMLInputElement >( null );
|
||||
|
@ -473,23 +478,21 @@ const PriceSlider = ( {
|
|||
) }
|
||||
{
|
||||
<div className="wc-block-components-price-slider__actions">
|
||||
{ ! isUpdating &&
|
||||
( minPrice !== minConstraint ||
|
||||
maxPrice !== maxConstraint ) && (
|
||||
<FilterResetButton
|
||||
onClick={ () => {
|
||||
onChange( [
|
||||
minConstraint,
|
||||
maxConstraint,
|
||||
] );
|
||||
debouncedUpdateQuery();
|
||||
} }
|
||||
screenReaderLabel={ __(
|
||||
'Reset price filter',
|
||||
'woo-gutenberg-products-block'
|
||||
) }
|
||||
/>
|
||||
) }
|
||||
{ ( isEditor ||
|
||||
( ! isUpdating &&
|
||||
( minPrice !== minConstraint ||
|
||||
maxPrice !== maxConstraint ) ) ) && (
|
||||
<FilterResetButton
|
||||
onClick={ () => {
|
||||
onChange( [ minConstraint, maxConstraint ] );
|
||||
debouncedUpdateQuery();
|
||||
} }
|
||||
screenReaderLabel={ __(
|
||||
'Reset price filter',
|
||||
'woo-gutenberg-products-block'
|
||||
) }
|
||||
/>
|
||||
) }
|
||||
{ showFilterButton && (
|
||||
<FilterSubmitButton
|
||||
className="wc-block-price-filter__button wc-block-components-price-slider__button"
|
||||
|
|
|
@ -353,6 +353,7 @@ const PriceFilterBlock = ( {
|
|||
onSubmit={ () => onSubmit( minPrice, maxPrice ) }
|
||||
isLoading={ isLoading }
|
||||
isUpdating={ isUpdating }
|
||||
isEditor={ isEditor }
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
|
|
|
@ -489,7 +489,7 @@ const RatingFilterBlock = ( {
|
|||
</div>
|
||||
{
|
||||
<div className="wc-block-rating-filter__actions">
|
||||
{ checked.length > 0 && ! isLoading && (
|
||||
{ ( checked.length > 0 || isEditor ) && ! isLoading && (
|
||||
<FilterResetButton
|
||||
onClick={ () => {
|
||||
setChecked( [] );
|
||||
|
|
|
@ -521,7 +521,7 @@ const StockStatusFilterBlock = ( {
|
|||
</div>
|
||||
{
|
||||
<div className="wc-block-stock-filter__actions">
|
||||
{ checked.length > 0 && ! isLoading && (
|
||||
{ ( checked.length > 0 || isEditor ) && ! isLoading && (
|
||||
<FilterResetButton
|
||||
onClick={ () => {
|
||||
setChecked( [] );
|
||||
|
|
Loading…
Reference in New Issue