]> source.dussan.org Git - sonarqube.git/commitdiff
scroll to top on route change
authorStas Vilchik <vilchiks@gmail.com>
Mon, 30 Jan 2017 15:09:14 +0000 (16:09 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 30 Jan 2017 15:09:27 +0000 (16:09 +0100)
server/sonar-web/src/main/js/app/utils/startReactApp.js

index e966592aa3afe8031b2e30435ab0de956a5114b4..85efd6a14c108c6f344ff71ba3c94ceeffaa727c 100644 (file)
@@ -68,6 +68,14 @@ import { globalPermissionsRoutes, projectPermissionsRoutes } from '../../apps/pe
 import getStore from './getStore';
 import getHistory from './getHistory';
 
+function handleUpdate () {
+  const { action } = this.state.location;
+
+  if (action === 'PUSH') {
+    window.scrollTo(0, 0);
+  }
+}
+
 const startReactApp = () => {
   const el = document.getElementById('content');
 
@@ -76,7 +84,7 @@ const startReactApp = () => {
 
   render((
       <Provider store={store}>
-        <Router history={history}>
+        <Router history={history} onUpdate={handleUpdate}>
           <Route path="/dashboard/index/:key" onEnter={(nextState, replace) => {
             replace({ pathname: '/dashboard', query: { id: nextState.params.key } });
           }}/>