summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLASER-Yi <[email protected]>2021-06-17 21:42:11 +0800
committerLASER-Yi <[email protected]>2021-06-17 21:42:11 +0800
commit030ca2a4e36bce65c75bd55a410cdc6777bcffca (patch)
tree0717cb0e758e04c40477f5851b6e80335c2d6127
parentb9c27d53ad51ab3f30a3d37148ffd1cca4a35b0c (diff)
downloadbazarr-030ca2a4e36bce65c75bd55a410cdc6777bcffca.tar.gz
bazarr-030ca2a4e36bce65c75bd55a410cdc6777bcffca.zip
Reset window position when backing to previous page
-rw-r--r--frontend/src/App/Router.tsx12
1 files changed, 8 insertions, 4 deletions
diff --git a/frontend/src/App/Router.tsx b/frontend/src/App/Router.tsx
index 72fd64409..772311da2 100644
--- a/frontend/src/App/Router.tsx
+++ b/frontend/src/App/Router.tsx
@@ -1,5 +1,6 @@
-import React, { FunctionComponent, useEffect, useMemo } from "react";
+import React, { FunctionComponent, useMemo } from "react";
import { Redirect, Route, Switch, useHistory } from "react-router-dom";
+import { useDidMount } from "rooks";
import { useIsRadarrEnabled, useIsSonarrEnabled } from "../@redux/hooks/site";
import BlacklistRouter from "../Blacklist/Router";
import HistoryRouter from "../History/Router";
@@ -26,9 +27,12 @@ const Router: FunctionComponent<{ className?: string }> = ({ className }) => {
const history = useHistory();
- useEffect(() => {
- ScrollToTop();
- }, [history.location]);
+ useDidMount(() => {
+ history.listen(() => {
+ // This is a hack to make sure ScrollToTop will be triggered in the next frame (When everything are loaded)
+ setTimeout(ScrollToTop);
+ });
+ });
return (
<div className={className}>