Browse Source

feat(webapp): don't scroll on navigation when only query is changed

Peter Thomassen 5 years ago
parent
commit
93ba14c434
1 changed files with 5 additions and 1 deletions
  1. 5 1
      webapp/src/router/index.js

+ 5 - 1
webapp/src/router/index.js

@@ -73,7 +73,11 @@ const routes = [
 const router = new VueRouter({
   mode: 'history',
   base: process.env.BASE_URL,
-  scrollBehavior () {
+  scrollBehavior (to, from) {
+    // Skip if destination full path has query parameters and differs in no other way from previous
+    if (from && Object.keys(to.query).length) {
+      if (to.fullPath.split('?')[0] == from.fullPath.split('?')[0]) return;
+    }
     return { x: 0, y: 0 }
   },
   routes