From 4c3901f22e1848aed3b7a422ca5f7058f961cf37 Mon Sep 17 00:00:00 2001 From: Adam Tomaszczyk Date: Tue, 12 Aug 2025 13:06:22 +0200 Subject: [PATCH] Search stops working after entering GA details and going back to Live Voting #4020 --- .../frontend/src/context/dataActionsBar.tsx | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/govtool/frontend/src/context/dataActionsBar.tsx b/govtool/frontend/src/context/dataActionsBar.tsx index 9ef913a26..e2776346c 100644 --- a/govtool/frontend/src/context/dataActionsBar.tsx +++ b/govtool/frontend/src/context/dataActionsBar.tsx @@ -68,18 +68,32 @@ const DataActionsBarProvider: FC = ({ children }) => { isAdjusting.current = false; }, []); + const gADetailsPathnameRegexp = /^.*\/governance_actions\/[a-fA-F0-9]{64}$/; const userMovedToDifferentAppArea = pathname !== lastPath && (!pathname.startsWith(lastPath) || lastPath === "" || lastPath === "/"); + const userOpenedGADetails = gADetailsPathnameRegexp.test(pathname); const userOpenedGADetailsFromCategoryPage = - lastPath.includes("governance_actions/category") && - pathname.includes("governance_actions/"); + userOpenedGADetails && + lastPath.includes("governance_actions/category"); const userMovedFromGAListToCategoryPage = lastPath.endsWith("governance_actions") && pathname.includes("governance_actions/category"); + const userMovedFromGADetailsToListOrCategoryPage = + (gADetailsPathnameRegexp.test(lastPath) && + pathname.includes("governance_actions")) || + pathname.includes("governance_actions/category"); useEffect(() => { isAdjusting.current = true; + if (userOpenedGADetails) { + return; + } + + if (userMovedFromGADetailsToListOrCategoryPage && debouncedSearchText.length > 0) { + isAdjusting.current = false; + return; + } if ( (!pathname.includes("drep_directory") && @@ -93,7 +107,7 @@ const DataActionsBarProvider: FC = ({ children }) => { useEffect(() => { setLastPath(pathname); - }, [searchText, chosenFilters, chosenSorting]); + }, [pathname, searchText, chosenFilters, chosenSorting]); const contextValue = useMemo( () => ({