Browse Source

tags.html: close open dropdown when user clicks elsewhere

Marc Foley 3 days ago
parent
commit
803e52469a
1 changed files with 9 additions and 0 deletions
  1. 9 0
      .ci/tags.html

+ 9 - 0
.ci/tags.html

@@ -413,6 +413,15 @@
       }
     } // methods
   )
+  // close open navbar dropdowns when user clicks elsewhere
+  var details = [...document.querySelectorAll('details')];
+  document.addEventListener('click', function(e) {
+  if (!details.some(f => f.contains(e.target))) {
+    details.forEach(f => f.removeAttribute('open'));
+  } else {
+    details.forEach(f => !f.contains(e.target) ? f.removeAttribute('open') : '');
+  }
+})
 </script>