File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { useWidget } from "./appReducer";
1111import useFeatureFlag from "./hooks/useFeatureFlag" ;
1212import SurveySnackbar from "./components/UI/SurveySnackbar" ;
1313import AnnouncementSnackbar from "components/UI/AnnouncementSnackbar" ;
14+ import ScrollToTop from "./components/ScrollToTop" ;
1415
1516const VerificationAdmin = lazy ( ( ) =>
1617 import ( "components/Admin/VerificationAdmin" )
@@ -241,6 +242,7 @@ function AppWrapper() {
241242 wrap = "nowrap"
242243 alignContent = "stretch"
243244 spacing = { 0 }
245+ id = "app-container"
244246 sx = { {
245247 color : "black" ,
246248 backgroundColor : "#fff" ,
@@ -249,6 +251,7 @@ function AppWrapper() {
249251 overflowX : "hidden" ,
250252 } }
251253 >
254+ < ScrollToTop />
252255 { isAlertLocation && < AnnouncementSnackbar /> }
253256
254257 { isWidget ? null : < Header /> }
Original file line number Diff line number Diff line change 1+ import { useEffect } from "react" ;
2+ import { useLocation } from "react-router-dom" ;
3+
4+ export default function ScrollToTop ( ) {
5+ const { pathname } = useLocation ( ) ;
6+
7+ useEffect ( ( ) => {
8+ // Scroll the window
9+ window . scrollTo ( 0 , 0 ) ;
10+
11+ // Scroll the app container (Grid with fixed height)
12+ const appContainer = document . getElementById ( "app-container" ) ;
13+ if ( appContainer ) {
14+ appContainer . scrollTop = 0 ;
15+ }
16+ } , [ pathname ] ) ;
17+
18+ return null ;
19+ }
You can’t perform that action at this time.
0 commit comments