Skip to content

Commit 80adea5

Browse files
committed
Reset to page 1 when clicking on filter cells
When clicking on a cell that applies a filter in a table (e.g. the presenters or series cell in the events table), the filter is applied but the page number is not reset, which can leave users on an empty page. This is confusing and not in line with how it works everywhere else, so this patch changes that.
1 parent 3efdff9 commit 80adea5

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/components/shared/FilterCell.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getFilters } from "../../selectors/tableFilterSelectors";
22
import { editFilterValue } from "../../slices/tableFilterSlice";
33
import { AppThunk, useAppDispatch, useAppSelector } from "../../store";
4-
import { Resource } from "../../slices/tableSlice";
4+
import { Resource, setOffset, setPageActive } from "../../slices/tableSlice";
55
import { AsyncThunk } from "@reduxjs/toolkit";
66
import { ParseKeys } from "i18next";
77
import { ReactNode } from "react";
@@ -36,6 +36,8 @@ const FilterCell = <T, >({
3636
const addFilter = async (filterValue: string) => {
3737
const filter = filterMap.find(({ name }) => name === filterName);
3838
if (filter) {
39+
dispatch(setOffset(0));
40+
dispatch(setPageActive(0));
3941
dispatch(editFilterValue({ filterName: filter.name, value: filterValue, resource }));
4042
await dispatch(fetchResource());
4143
dispatch(loadResourceIntoTable());

0 commit comments

Comments
 (0)