mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Fixed scroll position across the app (#2375)
* fixed scroll across the app * changes file
This commit is contained in:
parent
afc8bdd093
commit
53f82b8e28
2 changed files with 7 additions and 1 deletions
1
changes/issue-2242-app-scroll
Normal file
1
changes/issue-2242-app-scroll
Normal file
|
|
@ -0,0 +1 @@
|
|||
- Fixed scroll position when navigating to different pages
|
||||
|
|
@ -11,6 +11,7 @@ import { authToken } from "utilities/local";
|
|||
|
||||
interface IAppProps {
|
||||
children: JSX.Element;
|
||||
location: any; // no type in react-router v3
|
||||
}
|
||||
|
||||
interface IRootState {
|
||||
|
|
@ -22,7 +23,7 @@ interface IRootState {
|
|||
};
|
||||
}
|
||||
|
||||
export const AuthenticatedRoutes = ({ children }: IAppProps) => {
|
||||
export const AuthenticatedRoutes = ({ children, location }: IAppProps) => {
|
||||
const dispatch = useDispatch();
|
||||
const { user } = useSelector((state: IRootState) => state.auth);
|
||||
const { locationBeforeTransitions } = useSelector(
|
||||
|
|
@ -64,6 +65,10 @@ export const AuthenticatedRoutes = ({ children }: IAppProps) => {
|
|||
}
|
||||
}, [user]);
|
||||
|
||||
useDeepEffect(() => {
|
||||
window.scrollTo(0, 0);
|
||||
}, [location]);
|
||||
|
||||
if (!user) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue