Переглянути джерело

Fix bug where toggling the menu on mobile would jump to the top of the page

Robbie Averill 3 роки тому
батько
коміт
96e319db95
1 змінених файлів з 4 додано та 2 видалено
  1. 4 2
      resources/js/theme-default.js

+ 4 - 2
resources/js/theme-default.js

@@ -5,13 +5,15 @@ document.addEventListener('DOMContentLoaded', function() {
 
     const navButton = document.getElementById('nav-button');
     const menuWrapper = document.querySelector('.tocify-wrapper');
-    function toggleSidebar() {
+    function toggleSidebar(event) {
+        event.preventDefault();
         if (menuWrapper) {
             menuWrapper.classList.toggle('open');
             navButton.classList.toggle('open');
         }
     }
-    function closeSidebar() {
+    function closeSidebar(event) {
+        event.preventDefault();
         if (menuWrapper) {
             menuWrapper.classList.remove('open');
             navButton.classList.remove('open');