Browse Source

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

Robbie Averill 3 năm trước cách đây
mục cha
commit
96e319db95
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  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');