@@ -21864,8 +21864,13 @@ <h2>Download Other Formats</h2>
2186421864 }, 10);
2186521865 });
2186621866
21867- // Navigation click handlers
21867+ // Combined click handler for navigation and sidebar control
2186821868 document.addEventListener('click', function(e) {
21869+ const sidebar = document.getElementById('sidebar');
21870+ const mainContent = document.getElementById('main-content');
21871+ const isMobile = window.innerWidth <= 1024;
21872+
21873+ // Handle navigation item clicks
2186921874 if (e.target.closest('.nav-item[data-target]')) {
2187021875 e.preventDefault();
2187121876 const navItem = e.target.closest('.nav-item[data-target]');
@@ -21880,29 +21885,25 @@ <h2>Download Other Formats</h2>
2188021885 }
2188121886
2188221887 // Close sidebar on mobile after navigation
21883- if (window.innerWidth <= 1024) {
21884- const sidebar = document.getElementById('sidebar');
21885- const mainContent = document.getElementById('main-content');
21888+ if (isMobile) {
2188621889 sidebar.classList.remove('open');
2188721890 mainContent.classList.remove('sidebar-open');
2188821891 }
21892+ return; // Exit early
2188921893 }
21890- });
21891-
21892- // Close sidebar when clicking outside on mobile
21893- document.addEventListener('click', function(e) {
21894- if (window.innerWidth <= 1024) {
21895- const sidebar = document.getElementById('sidebar');
21896- const mainContent = document.getElementById('main-content');
21894+
21895+ // Handle clicking outside sidebar on mobile
21896+ if (isMobile && sidebar.classList.contains('open')) {
2189721897 const sidebarToggle = document.querySelector('.sidebar-toggle');
2189821898
21899- if (!sidebar.contains(e.target) && !sidebarToggle.contains(e.target) && sidebar.classList.contains('open') ) {
21899+ if (!sidebar.contains(e.target) && !sidebarToggle.contains(e.target)) {
2190021900 sidebar.classList.remove('open');
2190121901 mainContent.classList.remove('sidebar-open');
2190221902 }
2190321903 }
2190421904 });
2190521905
21906+
2190621907 // Handle window resize
2190721908 let resizeTimeout;
2190821909 window.addEventListener('resize', function() {
0 commit comments