auto close of items dropdown

This commit is contained in:
Harshil Vora
2025-06-12 01:33:38 -07:00
parent 6b2ccc501c
commit 22163f766d

View File

@@ -109,5 +109,24 @@
}); });
} }
}); });
/* ─── EIBS: allow only one open panel ─── */
const allCollapses = document.querySelectorAll('.collapse');
allCollapses.forEach(function (panel) {
/* When any panel STARTS to open… */
panel.addEventListener('show.bs.collapse', function () {
/* …loop through every other panel… */
allCollapses.forEach(function (openPanel) {
if (openPanel !== panel && openPanel.classList.contains('show')) {
/* …and close it. */
/* If Bootstrap already has an instance → use it, otherwise create one on the fly */
(bootstrap.Collapse.getInstance(openPanel) ||
new bootstrap.Collapse(openPanel))
.hide();
}
});
});
});
}); });
</script> </script>