From 1007117f0e5aa92828bcca264a2da763fc8a51a8 Mon Sep 17 00:00:00 2001 From: Mark Caron Date: Mon, 6 Oct 2025 11:16:57 -0400 Subject: [PATCH 1/3] fix: close overlay on mobile nav after hash link click --- static/js/page.js | 11 +++++++++++ templates/index.html | 1 + 2 files changed, 12 insertions(+) create mode 100644 static/js/page.js diff --git a/static/js/page.js b/static/js/page.js new file mode 100644 index 0000000..7791279 --- /dev/null +++ b/static/js/page.js @@ -0,0 +1,11 @@ +document.addEventListener('DOMContentLoaded', function() { + const mainNavHashLinks = document.querySelectorAll( + 'rh-navigation-primary-item[href^="#"], rh-navigation-primary-item > a[href^="#"]' + ); + + for (let hashLink of mainNavHashLinks) { + hashLink.addEventListener('click', function() { + hashLink.closest('rh-navigation-primary').close(); + }); + } +}); diff --git a/templates/index.html b/templates/index.html index 1f1caa0..e1e6e00 100644 --- a/templates/index.html +++ b/templates/index.html @@ -116,6 +116,7 @@

{{ elem.heading }}

{% include "partials/_footer.html" %} + From 72c4deb1de1ad9cd48cb4abb6a6fce13ac03845f Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 6 Oct 2025 12:14:02 -0400 Subject: [PATCH 2/3] docs: explain hashlink JS for main navigation --- static/js/page.js | 1 + 1 file changed, 1 insertion(+) diff --git a/static/js/page.js b/static/js/page.js index 7791279..14f01cb 100644 --- a/static/js/page.js +++ b/static/js/page.js @@ -3,6 +3,7 @@ document.addEventListener('DOMContentLoaded', function() { 'rh-navigation-primary-item[href^="#"], rh-navigation-primary-item > a[href^="#"]' ); + // Close dropdowns after clicking an in-page link on mobile viewports for (let hashLink of mainNavHashLinks) { hashLink.addEventListener('click', function() { hashLink.closest('rh-navigation-primary').close(); From 822bd1fc032d4b62c530b0d542875ff2f0ea603d Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 6 Oct 2025 12:15:06 -0400 Subject: [PATCH 3/3] style: comment spacing / formatting --- static/js/page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/page.js b/static/js/page.js index 14f01cb..d595a82 100644 --- a/static/js/page.js +++ b/static/js/page.js @@ -3,7 +3,7 @@ document.addEventListener('DOMContentLoaded', function() { 'rh-navigation-primary-item[href^="#"], rh-navigation-primary-item > a[href^="#"]' ); - // Close dropdowns after clicking an in-page link on mobile viewports + // Close dropdowns after clicking an in-page link on mobile viewports for (let hashLink of mainNavHashLinks) { hashLink.addEventListener('click', function() { hashLink.closest('rh-navigation-primary').close();