From 5d2a630a0750c742d526a739741448c0f8b7426b Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 6 Apr 2020 16:36:03 +0100 Subject: [PATCH] Use mousedown event so view switches before blur event prevents the switch (https://github.com/woocommerce/woocommerce-blocks/pull/2129) --- .../assets/js/components/view-switcher/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-blocks/assets/js/components/view-switcher/index.js b/plugins/woocommerce-blocks/assets/js/components/view-switcher/index.js index 61f5093116a..4f8e08eeeb9 100644 --- a/plugins/woocommerce-blocks/assets/js/components/view-switcher/index.js +++ b/plugins/woocommerce-blocks/assets/js/components/view-switcher/index.js @@ -41,8 +41,15 @@ const ViewSwitcher = ( { isPrimary={ currentView === view.value } isLarge aria-pressed={ currentView === view.value } + onMouseDown={ () => { + if ( currentView !== view.value ) { + setCurrentView( view.value ); + } + } } onClick={ () => { - setCurrentView( view.value ); + if ( currentView !== view.value ) { + setCurrentView( view.value ); + } } } > { view.name }