Skip to content

Commit e4fc556

Browse files
authored
fix: Explore scrolled down when navigating from dashboard (#20962)
1 parent 655646d commit e4fc556

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

superset-frontend/src/views/App.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import setupPlugins from 'src/setup/setupPlugins';
3535
import { routes, isFrontendRoute } from 'src/views/routes';
3636
import { Logger } from 'src/logger/LogUtils';
3737
import { RootContextProviders } from './RootContextProviders';
38+
import { ScrollToTop } from './ScrollToTop';
3839

3940
setupApp();
4041
setupPlugins();
@@ -60,6 +61,7 @@ const LocationPathnameLogger = () => {
6061

6162
const App = () => (
6263
<Router>
64+
<ScrollToTop />
6365
<LocationPathnameLogger />
6466
<RootContextProviders>
6567
<GlobalStyles />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { useEffect } from 'react';
21+
import { useLocation } from 'react-router-dom';
22+
23+
export const ScrollToTop = () => {
24+
const { pathname } = useLocation();
25+
26+
useEffect(() => {
27+
window.scrollTo(0, 0);
28+
}, [pathname]);
29+
30+
return null;
31+
};

0 commit comments

Comments
 (0)