clear searchMode along with search
This commit is contained in:
parent
b45825c015
commit
9398857d93
11
js/router.js
11
js/router.js
|
@ -78,9 +78,16 @@ const router = {
|
|||
router.update();
|
||||
},
|
||||
|
||||
updateSearch(key, value) {
|
||||
/**
|
||||
* @param {Object|string} what - an object or a single key
|
||||
* @param {string} [value] - for `key` mode
|
||||
*/
|
||||
updateSearch(what, value) {
|
||||
const u = new URL(location);
|
||||
u.searchParams[value ? 'set' : 'delete'](key, value);
|
||||
const entries = typeof what === 'object' ? Object.entries(what) : [[what, value]];
|
||||
for (const [key, val] of entries) {
|
||||
u.searchParams[val ? 'set' : 'delete'](key, val);
|
||||
}
|
||||
history.replaceState(history.state, null, `${u}`);
|
||||
router.update(true);
|
||||
},
|
||||
|
|
|
@ -114,7 +114,7 @@ function initFilters() {
|
|||
}
|
||||
}
|
||||
filterOnChange({forceRefilter: true});
|
||||
router.updateSearch('search', '');
|
||||
router.updateSearch({search: '', searchMode: ''});
|
||||
};
|
||||
|
||||
filterOnChange({forceRefilter: true});
|
||||
|
|
Loading…
Reference in New Issue
Block a user