From 87aec5fe624c4a39fb2fba3764c97434e39019f3 Mon Sep 17 00:00:00 2001 From: Talha Mahmood <36226639+Talha345@users.noreply.github.com> Date: Tue, 12 Sep 2023 17:08:40 +0200 Subject: [PATCH 1/2] Fix LHN toggle in responsive view! --- docs/assets/js/main.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/assets/js/main.js b/docs/assets/js/main.js index 01ebb00b288c..4d7c54793367 100644 --- a/docs/assets/js/main.js +++ b/docs/assets/js/main.js @@ -55,6 +55,7 @@ function navigateBack() { if (referrer.includes(currentHost) && window.history.length > 1) { window.history.back(); + toggleHeaderMenu(); return; } @@ -206,13 +207,6 @@ window.addEventListener('DOMContentLoaded', () => { // If there is a fixed article scroll container, set to calculate titles' offset scrollContainer: 'content-area', - - // onclick function to apply to all links in toc. will be called with - // the event as the first parameter, and this can be used to stop, - // propagation, prevent default or perform action - onClick() { - toggleHeaderMenu(); - }, }); } @@ -226,6 +220,18 @@ window.addEventListener('DOMContentLoaded', () => { const articleContent = document.getElementById('article-content'); const lhnContent = document.getElementById('lhn-content'); + + // This event listener checks if a link clicked in the LHN points to some section of the same page and toggles + // the LHN menu in responsive view. + lhnContent.addEventListener('click', (event) => { + const clickedLink = event.target; + if (clickedLink) { + const href = clickedLink.getAttribute('href'); + if (href && href.startsWith('#') && !!document.getElementById(href.slice(1))) { + toggleHeaderMenu(); + } + } + }); lhnContent.addEventListener('wheel', (e) => { const scrollTop = lhnContent.scrollTop; const isScrollingPastLHNTop = e.deltaY < 0 && scrollTop === 0; From dced65577a8b9bf6bba266a904c9acc462333f01 Mon Sep 17 00:00:00 2001 From: Talha Mahmood <36226639+Talha345@users.noreply.github.com> Date: Thu, 14 Sep 2023 20:44:58 +0200 Subject: [PATCH 2/2] Revert change! --- docs/assets/js/main.js | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/assets/js/main.js b/docs/assets/js/main.js index 4d7c54793367..f0f335536c20 100644 --- a/docs/assets/js/main.js +++ b/docs/assets/js/main.js @@ -55,7 +55,6 @@ function navigateBack() { if (referrer.includes(currentHost) && window.history.length > 1) { window.history.back(); - toggleHeaderMenu(); return; }