From 3036d6306ddd1600ca8c017d3bba56e4b6d2d967 Mon Sep 17 00:00:00 2001 From: Brian Glass Date: Mon, 17 Aug 2026 17:40:52 -0400 Subject: [PATCH] Close nav dropdowns on an outside click Native
only closes on a second click on its own (or when a sibling in the same name= group opens) -- it stays open if you click anywhere else on the page, which reads as broken for a nav dropdown. A single delegated click listener closes any open .topbar-inner > nav details whose subtree doesn't contain the click target, so clicks on the dropdown's own contents (its links) are left alone. Verified in-browser: opens on summary click, closes on an outside click, stays open when clicking a link inside it (so navigation isn't interrupted). Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01Hf6j2xXQXywHVh3HAVRxB3 --- orthocal/templates/base.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/orthocal/templates/base.html b/orthocal/templates/base.html index 4eed98d..733e5eb 100644 --- a/orthocal/templates/base.html +++ b/orthocal/templates/base.html @@ -111,6 +111,18 @@ toggle.setAttribute('aria-expanded', isOpen); }); }); + + // Native
only closes on a second click on its own + // (or when a sibling in the same name= group opens) -- + // it doesn't close on a click elsewhere on the page, which reads + // as broken for a nav dropdown. + document.addEventListener('click', function (event) { + document.querySelectorAll('.topbar-inner > nav details[open]').forEach(function (details) { + if (!details.contains(event.target)) { + details.removeAttribute('open'); + } + }); + }); {% block scripts %}{% endblock %}