Clear advanced filters when last one is removed

This commit is contained in:
Paul Sealock 2019-03-21 12:25:07 +13:00
parent 7423726786
commit 3474a26cb5
1 changed files with 5 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import {
getDefaultOptionValue, getDefaultOptionValue,
getNewPath, getNewPath,
getQueryFromActiveFilters, getQueryFromActiveFilters,
getHistory,
} from '@woocommerce/navigation'; } from '@woocommerce/navigation';
/** /**
@ -103,6 +104,10 @@ class AdvancedFilters extends Component {
const index = findIndex( activeFilters, filter => filter.key === key ); const index = findIndex( activeFilters, filter => filter.key === key );
activeFilters.splice( index, 1 ); activeFilters.splice( index, 1 );
this.setState( { activeFilters } ); this.setState( { activeFilters } );
if ( 0 === activeFilters.length ) {
const history = getHistory();
history.push( this.getUpdateHref( [] ) );
}
} }
getTitle() { getTitle() {