diff --git a/src/components/scroll-to-top.tsx b/src/components/scroll-to-top.tsx new file mode 100644 index 000000000..0eeb4c0ef --- /dev/null +++ b/src/components/scroll-to-top.tsx @@ -0,0 +1,11 @@ +import { useEffect } from "react"; +import { useLocation } from "react-router-dom"; + +export default function ScrollToTop() { + const { pathname } = useLocation(); + useEffect(() => { + document.getElementsByTagName('main')?.[0]?.scrollTo(0, 0); + }, [pathname]); + + return null; +} diff --git a/src/index.tsx b/src/index.tsx index 1aebd89e2..a73a4ec5b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -29,6 +29,7 @@ import ErrorBoundary from './components/ErrorBoundary'; import DashboardPage from './components/dashboard-page'; import ExtensionsEditorPage from './components/extensions-editor'; import GroupPage from './components/groups/GroupPage'; +import ScrollToTop from './components/scroll-to-top'; import { ThemeSwitcherProvider } from 'react-css-theme-switcher'; import i18n from './i18n'; @@ -55,6 +56,7 @@ const Main = () => { +