Filter by Attribute: Allow reselecting unselected attribute (https://github.com/woocommerce/woocommerce-blocks/pull/1264)
* Filter by Attribute: Allow reselecting unselected attribute * Run prettier
This commit is contained in:
parent
e8f0a071ba
commit
ec4ae1269d
|
@ -216,28 +216,31 @@ const Edit = ( { attributes, setAttributes, debouncedSpeak } ) => {
|
|||
);
|
||||
}, [] );
|
||||
|
||||
const onChange = useCallback( ( selected ) => {
|
||||
const selectedId = selected[ 0 ].id;
|
||||
const productAttribute = find( ATTRIBUTES, [
|
||||
'attribute_id',
|
||||
selectedId.toString(),
|
||||
] );
|
||||
const onChange = useCallback(
|
||||
( selected ) => {
|
||||
const selectedId = selected[ 0 ].id;
|
||||
const productAttribute = find( ATTRIBUTES, [
|
||||
'attribute_id',
|
||||
selectedId.toString(),
|
||||
] );
|
||||
|
||||
if ( ! productAttribute || attributeId === selectedId ) {
|
||||
return;
|
||||
}
|
||||
if ( ! productAttribute || attributeId === selectedId ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const attributeName = productAttribute.attribute_name;
|
||||
const attributeName = productAttribute.attribute_name;
|
||||
|
||||
setAttributes( {
|
||||
attributeId: selectedId,
|
||||
heading: sprintf(
|
||||
// Translators: %s attribute name.
|
||||
__( 'Filter by %s', 'woo-gutenberg-products-block' ),
|
||||
attributeName
|
||||
),
|
||||
} );
|
||||
}, [] );
|
||||
setAttributes( {
|
||||
attributeId: selectedId,
|
||||
heading: sprintf(
|
||||
// Translators: %s attribute name.
|
||||
__( 'Filter by %s', 'woo-gutenberg-products-block' ),
|
||||
attributeName
|
||||
),
|
||||
} );
|
||||
},
|
||||
[ attributeId ]
|
||||
);
|
||||
|
||||
const renderAttributeControl = () => {
|
||||
const messages = {
|
||||
|
|
Loading…
Reference in New Issue