Close all other navbar dropdowns when different one opens (fixes #59)

This commit is contained in:
daudix
2024-08-25 02:01:22 +03:00
parent 813f0cdf68
commit 3499501b44
2 changed files with 22 additions and 0 deletions

18
static/details.js Normal file
View File

@ -0,0 +1,18 @@
document.addEventListener("DOMContentLoaded", function () {
const nav = document.getElementById("site-nav");
const details = nav.querySelectorAll("details");
details.forEach((detail) => {
detail.addEventListener("toggle", () => {
if (detail.open) setTargetDetail(detail);
});
});
function setTargetDetail(targetDetail) {
details.forEach((detail) => {
if (detail !== targetDetail) {
detail.open = false;
}
});
}
})