onSubmit( checked ) }
- />
- ) }
+
+ { checked.length > 0 && (
+ {
+ setChecked( [] );
+ onSubmit( [] );
+ } }
+ screenReaderLabel={ __(
+ 'Reset stock filter',
+ 'woo-gutenberg-products-block'
+ ) }
+ />
+ ) }
+ { blockAttributes.showFilterButton && (
+ onSubmit( checked ) }
+ />
+ ) }
+
>
);
diff --git a/assets/js/blocks/stock-filter/edit.tsx b/assets/js/blocks/stock-filter/edit.tsx
index 05bdf6dd6b1..d3f079471b1 100644
--- a/assets/js/blocks/stock-filter/edit.tsx
+++ b/assets/js/blocks/stock-filter/edit.tsx
@@ -61,31 +61,13 @@ const Edit = ( {
} )
}
/>
-
- { __(
- 'Heading Level',
- 'woo-gutenberg-products-block'
- ) }
-
-
- setAttributes( { headingLevel: newLevel } )
- }
- />
+
+ { __( 'Size', 'woo-gutenberg-products-block' ) }
+
+ setAttributes( { headingLevel: newLevel } )
+ }
+ />
+
);
};
diff --git a/assets/js/blocks/stock-filter/style.scss b/assets/js/blocks/stock-filter/style.scss
index 60d9609e0db..705aad8ebae 100644
--- a/assets/js/blocks/stock-filter/style.scss
+++ b/assets/js/blocks/stock-filter/style.scss
@@ -24,4 +24,18 @@
.wc-block-stock-filter__button {
margin-top: $gap-smaller;
}
+
+ .wc-block-stock-filter__actions {
+ align-items: center;
+ display: flex;
+ gap: $gap;
+ justify-content: flex-end;
+ margin-top: $gap-large;
+
+ // The specificity here is needed to overwrite the margin-top that is inherited on WC block template pages such as Shop.
+ button[type="submit"]:not(.wp-block-search__button).wc-block-components-filter-submit-button {
+ margin-left: 0;
+ margin-top: 0;
+ }
+ }
}
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 cff704e558c..d6187701133 100644
--- a/assets/js/blocks/stock-filter/test/__snapshots__/block.js.snap
+++ b/assets/js/blocks/stock-filter/test/__snapshots__/block.js.snap
@@ -9,42 +9,102 @@ exports[`Testing stock filter renders the stock filter block 1`] = `
class="wc-block-checkbox-list wc-block-components-checkbox-list wc-block-stock-filter-list"
>
-
-
+
+
-
-
+
+
-
-
+
+
+
`;
@@ -58,57 +118,118 @@ exports[`Testing stock filter renders the stock filter block with the filter but
class="wc-block-checkbox-list wc-block-components-checkbox-list wc-block-stock-filter-list"
>
-
-
+
+
-
-
+
+
-
-
+
+
-
+
+ Apply
+
+
+ Apply filter
+
+
+
`;
@@ -122,84 +243,144 @@ exports[`Testing stock filter renders the stock filter block with the product co
class="wc-block-checkbox-list wc-block-components-checkbox-list wc-block-stock-filter-list"
>
-
-
+
+
-
-
+
+
-
-
+
+
+
`;
diff --git a/packages/checkout/components/checkbox-control/index.tsx b/packages/checkout/components/checkbox-control/index.tsx
index 063dd22460d..bbce84858e0 100644
--- a/packages/checkout/components/checkbox-control/index.tsx
+++ b/packages/checkout/components/checkbox-control/index.tsx
@@ -11,12 +11,13 @@ import './style.scss';
export type CheckboxControlProps = {
className?: string;
- label?: string;
+ label?: string | React.ReactNode;
id?: string;
onChange: ( value: boolean ) => void;
children?: React.ReactChildren;
hasError?: boolean;
checked?: boolean;
+ disabled?: boolean;
};
/**
@@ -30,6 +31,7 @@ export const CheckboxControl = ( {
children,
hasError = false,
checked = false,
+ disabled = false,
...rest
}: CheckboxControlProps ): JSX.Element => {
const instanceId = useInstanceId( CheckboxControl );
@@ -53,6 +55,7 @@ export const CheckboxControl = ( {
onChange={ ( event ) => onChange( event.target.checked ) }
aria-invalid={ hasError === true }
checked={ checked }
+ disabled={ disabled }
{ ...rest }
/>