Skip to content

Commit

Permalink
fix: Make sure to navigate to the explore page when filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
ipapandinas committed Jan 19, 2024
1 parent 057ceb1 commit e2908cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/filters/checkbox-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
};

Expand Down
3 changes: 2 additions & 1 deletion components/filters/select-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ export const SelectFilter = ({

const handleSelectionChange = (selection: unknown) => {
onSelect(Array.from(selection as Set<string>));
const currentPath = pathname === "/" ? "/explore/" : pathname;
const newUrl = createUrl(
placeholder,
Array.from(selection as Set<string>),
pathname,
currentPath,
);
router.replace(newUrl, { scroll: false });
};
Expand Down
3 changes: 2 additions & 1 deletion components/table/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
};

Expand Down

0 comments on commit e2908cd

Please sign in to comment.