aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2017-01-30 16:09:14 +0100
committerStas Vilchik <vilchiks@gmail.com>2017-01-30 16:09:27 +0100
commit130c80b174f0f5e0ce630d26360a4f9f804564d8 (patch)
treea0d5aeeb62487c7a100e080fc5b36e4dea1863dd
parent6daa377dda51dd0eb525cb8178d8de7b2702861b (diff)
downloadsonarqube-130c80b174f0f5e0ce630d26360a4f9f804564d8.tar.gz
sonarqube-130c80b174f0f5e0ce630d26360a4f9f804564d8.zip
scroll to top on route change
-rw-r--r--server/sonar-web/src/main/js/app/utils/startReactApp.js10
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 } });
}}/>