Fix filter clear all button.

This commit is contained in:
Mike Cao 2023-04-01 21:06:11 -07:00
parent 2411aeae8d
commit 8da72a693d
2 changed files with 4 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import usePageQuery from 'hooks/usePageQuery';
import styles from './FilterTags.module.css';
import useMessages from 'hooks/useMessages';
export default function FilterTags({ websiteId, params }) {
export default function FilterTags({ params }) {
const { formatMessage, labels } = useMessages();
const {
router,
@ -18,7 +18,7 @@ export default function FilterTags({ websiteId, params }) {
function handleCloseFilter(param) {
if (!param) {
router.push(`/websites/${websiteId}${view ? `?view=${view}` : ''}`);
router.push(resolveUrl({ view }, true));
} else {
router.push(resolveUrl({ [param]: undefined }));
}

View File

@ -23,8 +23,8 @@ export default function usePageQuery() {
}, {});
}, [search]);
function resolveUrl(params) {
return buildUrl(asPath.split('?')[0], { ...query, ...params });
function resolveUrl(params, reset) {
return buildUrl(asPath.split('?')[0], { ...(reset ? {} : query), ...params });
}
return { pathname, query, resolveUrl, router };