Use mousedown event so view switches before blur event prevents the switch (https://github.com/woocommerce/woocommerce-blocks/pull/2129)

This commit is contained in:
Mike Jolley 2020-04-06 16:36:03 +01:00 committed by GitHub
parent cc3ed31feb
commit 5d2a630a07
1 changed files with 8 additions and 1 deletions

View File

@ -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 }