Преглед изворни кода

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');