Clear filter button fixes (https://github.com/woocommerce/woocommerce-admin/pull/736)
This commit is contained in:
parent
81c746a22f
commit
9186eed9c0
|
@ -229,9 +229,11 @@ class AdvancedFilters extends Component {
|
||||||
{ __( 'Filter', 'wc-admin' ) }
|
{ __( 'Filter', 'wc-admin' ) }
|
||||||
</Link>
|
</Link>
|
||||||
) }
|
) }
|
||||||
<Link type="wc-admin" href={ this.getUpdateHref( [] ) } onClick={ this.clearFilters }>
|
{ activeFilters.length > 0 && (
|
||||||
{ __( 'Clear all filters', 'wc-admin' ) }
|
<Link type="wc-admin" href={ this.getUpdateHref( [] ) } onClick={ this.clearFilters }>
|
||||||
</Link>
|
{ __( 'Clear all filters', 'wc-admin' ) }
|
||||||
|
</Link>
|
||||||
|
) }
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|
|
@ -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 && (
|
||||||
{ __( 'Clear all', 'wc-admin' ) }
|
<Button isLink={ true } onClick={ this.clearQuery }>
|
||||||
</Link>
|
{ __( 'Clear all', 'wc-admin' ) }
|
||||||
|
</Button>
|
||||||
|
) }
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue