From 55054fcd02ac53fe5443a54b2d5863a2bfab3029 Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Tue, 3 Apr 2018 09:56:00 -0700 Subject: [PATCH] Jump direct to preview if no further settings are required woocommerce/woocommerce-blocks#68 --- plugins/woocommerce-blocks/assets/js/products-block.js | 7 ++++++- plugins/woocommerce-blocks/assets/js/products-block.jsx | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-blocks/assets/js/products-block.js b/plugins/woocommerce-blocks/assets/js/products-block.js index ba47c19a1b8..5e80469c2c2 100644 --- a/plugins/woocommerce-blocks/assets/js/products-block.js +++ b/plugins/woocommerce-blocks/assets/js/products-block.js @@ -836,10 +836,15 @@ registerBlockType('woocommerce/products', { function getSettingsEditor() { var update_display_callback = function update_display_callback(value) { + + // These options have setting screens that need further input from the user, so keep edit mode open. + var needsFurtherSettings = ['specific', 'attribute', 'category']; + if (display !== value) { setAttributes({ display: value, - display_setting: [] + display_setting: [], + edit_mode: needsFurtherSettings.includes(value) }); } }; diff --git a/plugins/woocommerce-blocks/assets/js/products-block.jsx b/plugins/woocommerce-blocks/assets/js/products-block.jsx index 3d5623cf3ed..ac7709be143 100644 --- a/plugins/woocommerce-blocks/assets/js/products-block.jsx +++ b/plugins/woocommerce-blocks/assets/js/products-block.jsx @@ -572,10 +572,15 @@ registerBlockType( 'woocommerce/products', { function getSettingsEditor() { const update_display_callback = ( value ) => { + + // These options have setting screens that need further input from the user, so keep edit mode open. + const needsFurtherSettings = [ 'specific', 'attribute', 'category' ]; + if ( display !== value ) { setAttributes( { display: value, display_setting: [], + edit_mode: needsFurtherSettings.includes( value ), } ); } };