@@ -8,6 +8,7 @@ import React, {
88 useEffect ,
99 useMemo ,
1010 FC ,
11+ useRef ,
1112} from "react" ;
1213import { useLocation } from "react-router-dom" ;
1314
@@ -41,7 +42,7 @@ interface ProviderProps {
4142}
4243
4344const DataActionsBarProvider : FC < ProviderProps > = ( { children } ) => {
44- const [ isAdjusting , setIsAdjusting ] = useState < boolean > ( true ) ;
45+ const isAdjusting = useRef < boolean > ( false ) ;
4546 const [ searchText , setSearchText ] = useState < string > ( "" ) ;
4647 const debouncedSearchText = useDebounce ( searchText , 300 ) ;
4748 const [ filtersOpen , setFiltersOpen ] = useState < boolean > ( false ) ;
@@ -64,11 +65,12 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
6465 setSearchText ( "" ) ;
6566 setChosenFilters ( [ ] ) ;
6667 setChosenSorting ( "" ) ;
67- setIsAdjusting ( false ) ;
68+ isAdjusting . current = false ;
6869 } , [ ] ) ;
6970
7071 const userMovedToDifferentAppArea =
71- pathname !== lastPath && ! pathname . startsWith ( lastPath ) ;
72+ pathname !== lastPath &&
73+ ( ! pathname . startsWith ( lastPath ) || lastPath === "" ) ;
7274 const userOpenedGADetailsFromCategoryPage =
7375 lastPath . includes ( "governance_actions/category" ) &&
7476 pathname . includes ( "governance_actions/" ) ;
@@ -77,7 +79,8 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
7779 pathname . includes ( "governance_actions/category" ) ;
7880
7981 useEffect ( ( ) => {
80- setIsAdjusting ( true ) ;
82+ isAdjusting . current = true ;
83+
8184 if (
8285 ( ! pathname . includes ( "drep_directory" ) &&
8386 userMovedToDifferentAppArea &&
@@ -94,7 +97,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
9497
9598 const contextValue = useMemo (
9699 ( ) => ( {
97- isAdjusting,
100+ isAdjusting : isAdjusting . current ,
98101 chosenFilters,
99102 chosenFiltersLength : chosenFilters . length ,
100103 chosenSorting,
@@ -111,7 +114,6 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
111114 sortOpen,
112115 } ) ,
113116 [
114- isAdjusting ,
115117 chosenFilters ,
116118 chosenSorting ,
117119 debouncedSearchText ,
@@ -120,6 +122,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
120122 sortOpen ,
121123 closeFilters ,
122124 closeSorts ,
125+ pathname ,
123126 ] ,
124127 ) ;
125128
0 commit comments