From c809ccb849832dcae97f60fb8e6058bf94449641 Mon Sep 17 00:00:00 2001 From: Alzer Del Zeyger <75466035+Dx-Alz-xD@users.noreply.github.com> Date: Tue, 1 Dec 2026 20:40:13 +0530 Subject: [PATCH] fix(catalogue): clear the selected papers when the subject changes moving to another subject from the catalogue, for example through a related subject, keeps the page and its filter context mounted, so the papers picked on the last subject stayed selected. the count showed them, select all could read as already done, and download selected zipped them under the new subject's name. the selection now resets whenever the subject changes fixes #577 --- src/context/filterContext.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/context/filterContext.tsx b/src/context/filterContext.tsx index e4df4ad..a8c1041 100644 --- a/src/context/filterContext.tsx +++ b/src/context/filterContext.tsx @@ -5,6 +5,7 @@ import React, { useContext, useState, useCallback, + useEffect, useMemo, useRef, type ReactNode, @@ -107,6 +108,10 @@ export const FilterProvider: React.FC = ({ const [selectedPapers, setSelectedPapers] = useState([]); const [filterOptions, setFilterOptions] = useState(); + useEffect(() => { + setSelectedPapers([]); + }, [subject]); + const [filtersPulled, setFiltersPulled] = useState(false); const [appliedFilters, setAppliedFilters] = useState(false); const [currentPage, setCurrentPage] = useState(1);