Yuki Takei 4 лет назад
Родитель
Сommit
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);
     }));