Table: reset search on compare and reset comparison on search (https://github.com/woocommerce/woocommerce-admin/pull/1679)

This commit is contained in:
Albert Juhé Lluveras 2019-02-25 20:40:30 +01:00 committed by GitHub
parent 4a19d27ec1
commit 365d493079
2 changed files with 7 additions and 2 deletions

View File

@ -151,7 +151,7 @@ class TableCard extends Component {
}
onSearch( values ) {
const { compareParam } = this.props;
const { compareParam, searchBy } = this.props;
// A comma is used as a separator between search terms, so we want to escape
// any comma they contain.
const labels = values.map( v => v.label.replace( ',', '%2C' ) );
@ -159,6 +159,7 @@ class TableCard extends Component {
updateQueryString( {
filter: undefined,
[ compareParam ]: undefined,
[ searchBy ]: undefined,
search: uniq( labels ).join( ',' ),
} );
} else {

View File

@ -110,7 +110,11 @@ export function onQueryChange( param, path = getPath(), query = getQuery() ) {
return ( key, dir ) => updateQueryString( { orderby: key, order: dir }, path, query );
case 'compare':
return ( key, queryParam, ids ) =>
updateQueryString( { [ queryParam ]: `compare-${ key }`, [ key ]: ids }, path, query );
updateQueryString( {
[ queryParam ]: `compare-${ key }`,
[ key ]: ids,
search: undefined,
}, path, query );
default:
return value => updateQueryString( { [ param ]: value }, path, query );
}