Ensure Filter Products by Attribute block reloads the page when interacting with PHP templates (https://github.com/woocommerce/woocommerce-blocks/pull/6332)
This commit is contained in:
parent
1d0acebfa9
commit
81f348b466
|
@ -274,29 +274,36 @@ const AttributeFilterBlock = ( {
|
|||
[ pageUrl, attributeObject?.taxonomy ]
|
||||
);
|
||||
|
||||
const onClickSubmit = ( isChecked ) => {
|
||||
const query = updateAttributeFilter(
|
||||
productAttributesQuery,
|
||||
setProductAttributesQuery,
|
||||
attributeObject,
|
||||
getSelectedTerms( isChecked ),
|
||||
blockAttributes.queryType === 'or' ? 'in' : 'and'
|
||||
);
|
||||
|
||||
// This is for PHP rendered template filtering only.
|
||||
if ( filteringForPhpTemplate ) {
|
||||
redirectPageForPhpTemplate( query, isChecked.length === 0 );
|
||||
}
|
||||
};
|
||||
|
||||
const onSubmit = useCallback(
|
||||
( isChecked ) => {
|
||||
if ( isEditor ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const query = updateAttributeFilter(
|
||||
updateAttributeFilter(
|
||||
productAttributesQuery,
|
||||
setProductAttributesQuery,
|
||||
attributeObject,
|
||||
getSelectedTerms( isChecked ),
|
||||
blockAttributes.queryType === 'or' ? 'in' : 'and'
|
||||
);
|
||||
|
||||
// This is for PHP rendered template filtering only.
|
||||
if ( filteringForPhpTemplate && hasSetPhpFilterDefaults ) {
|
||||
redirectPageForPhpTemplate( query, isChecked.length === 0 );
|
||||
}
|
||||
},
|
||||
[
|
||||
hasSetPhpFilterDefaults,
|
||||
filteringForPhpTemplate,
|
||||
redirectPageForPhpTemplate,
|
||||
isEditor,
|
||||
productAttributesQuery,
|
||||
setProductAttributesQuery,
|
||||
|
@ -588,7 +595,7 @@ const AttributeFilterBlock = ( {
|
|||
<FilterSubmitButton
|
||||
className="wc-block-attribute-filter__button"
|
||||
disabled={ isLoading || isDisabled }
|
||||
onClick={ () => onSubmit( checked ) }
|
||||
onClick={ () => onClickSubmit( checked ) }
|
||||
/>
|
||||
) }
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue