Skip to content

Commit 73ea4c7

Browse files
authored
Merge pull request #4026 from IntersectMBO/issue-4020
Search stops working after entering GA details and going back to Live Voting #4020
2 parents bc6df24 + 4c3901f commit 73ea4c7

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

govtool/frontend/src/context/dataActionsBar.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,32 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
6868
isAdjusting.current = false;
6969
}, []);
7070

71+
const gADetailsPathnameRegexp = /^.*\/governance_actions\/[a-fA-F0-9]{64}$/;
7172
const userMovedToDifferentAppArea =
7273
pathname !== lastPath &&
7374
(!pathname.startsWith(lastPath) || lastPath === "" || lastPath === "/");
75+
const userOpenedGADetails = gADetailsPathnameRegexp.test(pathname);
7476
const userOpenedGADetailsFromCategoryPage =
75-
lastPath.includes("governance_actions/category") &&
76-
pathname.includes("governance_actions/");
77+
userOpenedGADetails &&
78+
lastPath.includes("governance_actions/category");
7779
const userMovedFromGAListToCategoryPage =
7880
lastPath.endsWith("governance_actions") &&
7981
pathname.includes("governance_actions/category");
82+
const userMovedFromGADetailsToListOrCategoryPage =
83+
(gADetailsPathnameRegexp.test(lastPath) &&
84+
pathname.includes("governance_actions")) ||
85+
pathname.includes("governance_actions/category");
8086

8187
useEffect(() => {
8288
isAdjusting.current = true;
89+
if (userOpenedGADetails) {
90+
return;
91+
}
92+
93+
if (userMovedFromGADetailsToListOrCategoryPage && debouncedSearchText.length > 0) {
94+
isAdjusting.current = false;
95+
return;
96+
}
8397

8498
if (
8599
(!pathname.includes("drep_directory") &&
@@ -93,7 +107,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
93107

94108
useEffect(() => {
95109
setLastPath(pathname);
96-
}, [searchText, chosenFilters, chosenSorting]);
110+
}, [pathname, searchText, chosenFilters, chosenSorting]);
97111

98112
const contextValue = useMemo(
99113
() => ({

0 commit comments

Comments
 (0)