diff --git a/plugins/woocommerce-blocks/assets/js/products-block.js b/plugins/woocommerce-blocks/assets/js/products-block.js index 90fb918e0b9..2a86f1d46e6 100644 --- a/plugins/woocommerce-blocks/assets/js/products-block.js +++ b/plugins/woocommerce-blocks/assets/js/products-block.js @@ -798,12 +798,20 @@ registerBlockType('woocommerce/products', { * @return Component */ function getSettingsEditor() { + + var update_display_callback = function update_display_callback(value) { + if (display !== value) { + setAttributes({ + display: value, + display_setting: [] + }); + } + }; + return wp.element.createElement(ProductsBlockSettingsEditor, { selected_display: display, selected_display_setting: display_setting, - update_display_callback: function update_display_callback(value) { - return setAttributes({ display: value }); - }, + update_display_callback: update_display_callback, update_display_setting_callback: function update_display_setting_callback(value) { return setAttributes({ display_setting: value }); }, diff --git a/plugins/woocommerce-blocks/assets/js/products-block.jsx b/plugins/woocommerce-blocks/assets/js/products-block.jsx index a2a703621a5..05fe6c837ee 100644 --- a/plugins/woocommerce-blocks/assets/js/products-block.jsx +++ b/plugins/woocommerce-blocks/assets/js/products-block.jsx @@ -526,11 +526,21 @@ registerBlockType( 'woocommerce/products', { * @return Component */ function getSettingsEditor() { + + const update_display_callback = ( value ) => { + if ( display !== value ) { + setAttributes( { + display: value, + display_setting: [], + } ); + } + }; + return ( setAttributes( { display: value } ) } + update_display_callback={ update_display_callback } update_display_setting_callback={ ( value ) => setAttributes( { display_setting: value } ) } done_callback={ () => setAttributes( { edit_mode: false } ) } />