Fix collapsing navbar dropdown when clicking another element

JavaScript was checking if element clicked is exactly .nav-summary,
which isn't a problem when just clicking text inside it, but if we try
to click another element inside like <span>, it won't work, since now
this span is clicked, not .nav-summary.

Closes #1549
This commit is contained in:
Dawid Potocki 2019-12-01 14:47:39 +13:00
parent 26b3382461
commit e80abf622b
No known key found for this signature in database
GPG Key ID: D4045195AB86173B

View File

@ -25,7 +25,11 @@ function navSectionsToggle() {
function navSectionsClose(event) { function navSectionsClose(event) {
// Hide all dropdowns when clicking in different place // Hide all dropdowns when clicking in different place
if (event.target.matches(".nav-summary")) return; if (
event.target.matches(".nav-summary") ||
event.target.parentNode.matches(".nav-summary")
)
return;
navSections.forEach(navSection => { navSections.forEach(navSection => {
navSection.open = !open; navSection.open = !open;
}); });