clear searchMode along with search

This commit is contained in:
tophf 2022-09-06 01:07:14 +03:00
parent b45825c015
commit 9398857d93
2 changed files with 10 additions and 3 deletions

View File

@ -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);
},

View File

@ -114,7 +114,7 @@ function initFilters() {
}
}
filterOnChange({forceRefilter: true});
router.updateSearch('search', '');
router.updateSearch({search: '', searchMode: ''});
};
filterOnChange({forceRefilter: true});