Yuki Takei пре 4 година
родитељ
комит
41fb190fe6
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3 1
      packages/app/src/client/services/NavigationContainer.js

+ 3 - 1
packages/app/src/client/services/NavigationContainer.js

@@ -131,10 +131,12 @@ export default class NavigationContainer extends Container {
    */
   addSmoothScrollEvent(elements = {}) {
     elements.forEach(link => link.addEventListener('click', (e) => {
+      // modify location.hash without scroll
       e.preventDefault();
+      window.history.pushState({}, '', link.href);
 
+      // smooth scroll
       const href = link.getAttribute('href').replace('#', '');
-      window.location.hash = href;
       const targetDom = document.getElementById(href);
       this.smoothScrollIntoView(targetDom, WIKI_HEADER_LINK);
     }));