From e2908cd5a322bec966390bc9df625dd1948baa1f Mon Sep 17 00:00:00 2001 From: Igor Papandinas Date: Fri, 19 Jan 2024 18:12:13 +0100 Subject: [PATCH] fix: Make sure to navigate to the explore page when filtering --- components/filters/checkbox-filter.tsx | 3 ++- components/filters/select-filter.tsx | 3 ++- components/table/row.tsx | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/filters/checkbox-filter.tsx b/components/filters/checkbox-filter.tsx index fa326b3..a385126 100644 --- a/components/filters/checkbox-filter.tsx +++ b/components/filters/checkbox-filter.tsx @@ -22,7 +22,8 @@ export const CheckboxFilter = ({ const handleValueChange = (value: boolean) => { const newValue = value ? [value.toString()] : []; onSelect(newValue); - const newUrl = createUrl(paramKey, newValue, pathname); + const currentPath = pathname === "/" ? "/explore/" : pathname; + const newUrl = createUrl(paramKey, newValue, currentPath); router.replace(newUrl, { scroll: false }); }; diff --git a/components/filters/select-filter.tsx b/components/filters/select-filter.tsx index 1f1e122..1417503 100644 --- a/components/filters/select-filter.tsx +++ b/components/filters/select-filter.tsx @@ -27,10 +27,11 @@ export const SelectFilter = ({ const handleSelectionChange = (selection: unknown) => { onSelect(Array.from(selection as Set)); + const currentPath = pathname === "/" ? "/explore/" : pathname; const newUrl = createUrl( placeholder, Array.from(selection as Set), - pathname, + currentPath, ); router.replace(newUrl, { scroll: false }); }; diff --git a/components/table/row.tsx b/components/table/row.tsx index 0ff962d..c7cc107 100644 --- a/components/table/row.tsx +++ b/components/table/row.tsx @@ -164,7 +164,8 @@ export const Labels = ({ const handleClick = (key: FilterKeys, values: string[]) => { updateFilter(key, values); - const newUrl = createUrl(key, values, pathname); + const currentPath = pathname === "/" ? "/explore/" : pathname; + const newUrl = createUrl(key, values, currentPath); router.replace(newUrl, { scroll: false }); };