Skip to content

Commit 9d085d3

Browse files
committed
pagination for topic and subject
1 parent a532ba8 commit 9d085d3

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/containers/SearchPage/GrepFilter.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ export const GrepFilter = () => {
7676
});
7777

7878
useEffect(() => {
79-
if (nodeType && nodeType !== RESOURCE_NODE_TYPE) {
79+
if (nodeType && nodeType !== RESOURCE_NODE_TYPE && codes.length) {
8080
setSearchParams({ grepCodes: null });
8181
}
82-
}, [nodeType, setSearchParams]);
82+
}, [codes.length, nodeType, setSearchParams]);
8383

8484
// const groupedCompetenceGoals = useMemo(() => {
8585
// return groupCompetenceGoals(grepQuery.data?.competenceGoals ?? [], true, "LK20");

src/containers/SearchPage/SearchContainer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ export const SearchContainer = ({ resourceTypes, resourceTypesLoading }: Props)
465465
onClick={() => {
466466
const prevPage = page - 1;
467467
setPage(prevPage);
468-
setSearchParams({ page: prevPage.toString() });
468+
setSearchParams({ page: prevPage === 1 ? null : prevPage.toString() });
469469
focusRef.current?.focus();
470470
}}
471471
>

src/containers/SearchPage/SubjectFilter.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ export const SubjectFilter = () => {
8787
});
8888

8989
useEffect(() => {
90-
if (nodeType === SUBJECT_NODE_TYPE) {
90+
if (nodeType && nodeType === SUBJECT_NODE_TYPE && searchParams.get("subjects")) {
9191
setSearchParams({ subjects: null });
9292
}
93-
}, [nodeType, setSearchParams]);
93+
}, [nodeType, searchParams, setSearchParams]);
9494

9595
const activeSubjectIds = useMemo(() => searchParams.get("subjects")?.split(",") ?? [], [searchParams]);
9696

src/containers/SearchPage/TraitFilter.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export const TraitFilter = () => {
3131
const nodeType = searchParams.get("type");
3232

3333
useEffect(() => {
34-
if (nodeType && nodeType !== RESOURCE_NODE_TYPE) {
34+
if (nodeType && nodeType !== RESOURCE_NODE_TYPE && searchParams.get("traits")) {
3535
setSearchParams({ traits: null });
3636
}
37-
}, [nodeType, setSearchParams]);
37+
}, [nodeType, searchParams, setSearchParams]);
3838

3939
const onValueChange = useCallback(
4040
(traits: string[]) => {

0 commit comments

Comments
 (0)