File tree Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Expand file tree Collapse file tree 1 file changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -41,16 +41,7 @@ export default function CamerasListPage() {
41
41
const [ searchText , setSearchText ] = useState ( '' ) ;
42
42
43
43
// UseEffect hooks and data functions
44
- useEffect ( ( ) => {
45
- const scrollPosition = sessionStorage . getItem ( 'scrollPosition' ) ;
46
- if ( scrollPosition ) {
47
- window . scrollTo ( 0 , parseInt ( scrollPosition , 10 ) ) ;
48
- }
49
- } ) ;
50
-
51
44
const getCamerasData = async ( ) => {
52
- isInitialMount . current = false ;
53
-
54
45
const newRouteTimestamp = selectedRoute ? selectedRoute . searchTimestamp : null ;
55
46
56
47
let tempCams = cameras ;
@@ -100,6 +91,23 @@ export default function CamerasListPage() {
100
91
101
92
} , [ searchText , processedCameras ] ) ;
102
93
94
+ useEffect ( ( ) => {
95
+ if ( isInitialMount . current ) {
96
+ const scrollPosition = sessionStorage . getItem ( 'scrollPosition' ) ;
97
+ if ( scrollPosition ) {
98
+ setTimeout ( function ( ) {
99
+ window . scrollTo ( {
100
+ top : parseInt ( scrollPosition , 10 ) ,
101
+ left : 0 ,
102
+ behavior : "smooth"
103
+ } ) ;
104
+ } , 300 ) ;
105
+ }
106
+
107
+ isInitialMount . current = false ;
108
+ }
109
+ } , [ displayedCameras ] ) ;
110
+
103
111
return (
104
112
< div className = "cameras-page" >
105
113
< PageHeader
You can’t perform that action at this time.
0 commit comments