You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2022/09/20 20:50:16 UTC
[superset] 06/29: fix: Explore scrolled down when navigating from dashboard (#20962)
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch 2.0-test
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 346c035690524f564421af6c18e4911c9ee5a268
Author: Kamil Gabryjelski <ka...@gmail.com>
AuthorDate: Wed Aug 3 21:55:52 2022 +0200
fix: Explore scrolled down when navigating from dashboard (#20962)
(cherry picked from commit e4fc5564ced1e2ad2f475629ce082ededd063ba9)
---
superset-frontend/src/views/App.tsx | 2 ++
superset-frontend/src/views/ScrollToTop.tsx | 31 +++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/superset-frontend/src/views/App.tsx b/superset-frontend/src/views/App.tsx
index 04ca777c3d..ecdbddbd56 100644
--- a/superset-frontend/src/views/App.tsx
+++ b/superset-frontend/src/views/App.tsx
@@ -35,6 +35,7 @@ import setupApp from 'src/setup/setupApp';
import { routes, isFrontendRoute } from 'src/views/routes';
import { Logger } from 'src/logger/LogUtils';
import { RootContextProviders } from './RootContextProviders';
+import { ScrollToTop } from './ScrollToTop';
setupApp();
@@ -60,6 +61,7 @@ const LocationPathnameLogger = () => {
const App = () => (
<Router>
+ <ScrollToTop />
<LocationPathnameLogger />
<RootContextProviders>
<GlobalStyles />
diff --git a/superset-frontend/src/views/ScrollToTop.tsx b/superset-frontend/src/views/ScrollToTop.tsx
new file mode 100644
index 0000000000..283f1b4208
--- /dev/null
+++ b/superset-frontend/src/views/ScrollToTop.tsx
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { useEffect } from 'react';
+import { useLocation } from 'react-router-dom';
+
+export const ScrollToTop = () => {
+ const { pathname } = useLocation();
+
+ useEffect(() => {
+ window.scrollTo(0, 0);
+ }, [pathname]);
+
+ return null;
+};