From 866a634e9d94b1db78b388b26bd9bb80f20d2aab Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Fri, 2 Mar 2018 09:39:12 -0800 Subject: [PATCH] Reset display setting when display changes to prevent e.g. product ids in the category select --- .../woocommerce-blocks/assets/js/products-block.js | 14 +++++++++++--- .../assets/js/products-block.jsx | 12 +++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) 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 } ) } />