diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2017-01-30 16:09:14 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2017-01-30 16:09:27 +0100 |
commit | 130c80b174f0f5e0ce630d26360a4f9f804564d8 (patch) | |
tree | a0d5aeeb62487c7a100e080fc5b36e4dea1863dd | |
parent | 6daa377dda51dd0eb525cb8178d8de7b2702861b (diff) | |
download | sonarqube-130c80b174f0f5e0ce630d26360a4f9f804564d8.tar.gz sonarqube-130c80b174f0f5e0ce630d26360a4f9f804564d8.zip |
scroll to top on route change
-rw-r--r-- | server/sonar-web/src/main/js/app/utils/startReactApp.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/server/sonar-web/src/main/js/app/utils/startReactApp.js b/server/sonar-web/src/main/js/app/utils/startReactApp.js index e966592aa3a..85efd6a14c1 100644 --- a/server/sonar-web/src/main/js/app/utils/startReactApp.js +++ b/server/sonar-web/src/main/js/app/utils/startReactApp.js @@ -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 } }); }}/> |