This commit is contained in:
Albert Juhé Lluveras 2018-10-31 11:29:20 +01:00 committed by GitHub
parent 81c746a22f
commit 9186eed9c0
2 changed files with 18 additions and 9 deletions

View File

@ -229,9 +229,11 @@ class AdvancedFilters extends Component {
{ __( 'Filter', 'wc-admin' ) } { __( 'Filter', 'wc-admin' ) }
</Link> </Link>
) } ) }
{ activeFilters.length > 0 && (
<Link type="wc-admin" href={ this.getUpdateHref( [] ) } onClick={ this.clearFilters }> <Link type="wc-admin" href={ this.getUpdateHref( [] ) } onClick={ this.clearFilters }>
{ __( 'Clear all filters', 'wc-admin' ) } { __( 'Clear all filters', 'wc-admin' ) }
</Link> </Link>
) }
</div> </div>
</Card> </Card>
); );

View File

@ -4,6 +4,7 @@
*/ */
import { __ } from '@wordpress/i18n'; import { __ } from '@wordpress/i18n';
import { Component } from '@wordpress/element'; import { Component } from '@wordpress/element';
import { Button } from '@wordpress/components';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
@ -12,8 +13,7 @@ import PropTypes from 'prop-types';
*/ */
import Card from 'components/card'; import Card from 'components/card';
import CompareButton from './button'; import CompareButton from './button';
import Link from 'components/link'; import { getIdsFromQuery, updateQueryString } from 'lib/nav-utils';
import { getIdsFromQuery, getNewPath, updateQueryString } from 'lib/nav-utils';
import Search from 'components/search'; import Search from 'components/search';
/** /**
@ -54,7 +54,12 @@ class CompareFilter extends Component {
clearQuery() { clearQuery() {
const { param, path, query } = this.props; const { param, path, query } = this.props;
return getNewPath( { [ param ]: undefined }, path, query );
this.setState( {
selected: [],
} );
updateQueryString( { [ param ]: undefined }, path, query );
} }
updateLabels( selected ) { updateLabels( selected ) {
@ -91,9 +96,11 @@ class CompareFilter extends Component {
> >
{ labels.update } { labels.update }
</CompareButton> </CompareButton>
<Link type="wc-admin" href={ this.clearQuery() }> { selected.length > 0 && (
<Button isLink={ true } onClick={ this.clearQuery }>
{ __( 'Clear all', 'wc-admin' ) } { __( 'Clear all', 'wc-admin' ) }
</Link> </Button>
) }
</div> </div>
</Card> </Card>
); );