Skip to content

Commit cb75893

Browse files
committed
Fix explorer dropdown functionality
1 parent e579212 commit cb75893

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/js/inline-handlers.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ function toggleCheckboxDropdown(dropdownId) {
4242
document.querySelectorAll('.checkbox-dropdown-menu').forEach(m => {
4343
if (m !== menu && m.classList.contains('show')) {
4444
m.classList.remove('show');
45-
const otherArrow = m.previousElementSibling.querySelector('.dropdown-arrow');
45+
const otherTrigger = m.previousElementSibling;
46+
if (otherTrigger) otherTrigger.classList.remove('open');
47+
const otherArrow = m.previousElementSibling?.querySelector('.dropdown-arrow');
4648
if (otherArrow) otherArrow.style.transform = 'rotate(0deg)';
4749
// Clear search in the closed dropdown
4850
const otherSearch = m.querySelector('.dropdown-search');
@@ -56,7 +58,8 @@ function toggleCheckboxDropdown(dropdownId) {
5658
// Toggle current dropdown
5759
if (menu.classList.contains('show')) {
5860
menu.classList.remove('show');
59-
arrow.style.transform = 'rotate(0deg)';
61+
if (trigger) trigger.classList.remove('open');
62+
if (arrow) arrow.style.transform = 'rotate(0deg)';
6063
// Clear search when closing
6164
const search = menu.querySelector('.dropdown-search');
6265
if (search && search.value) {
@@ -65,7 +68,8 @@ function toggleCheckboxDropdown(dropdownId) {
6568
}
6669
} else {
6770
menu.classList.add('show');
68-
arrow.style.transform = 'rotate(180deg)';
71+
if (trigger) trigger.classList.add('open');
72+
if (arrow) arrow.style.transform = 'rotate(180deg)';
6973
// Focus search input when opening
7074
const search = menu.querySelector('.dropdown-search');
7175
if (search) setTimeout(() => search.focus(), 50);
@@ -200,10 +204,12 @@ function initCheckboxDropdowns() {
200204

201205
// Close dropdowns when clicking outside
202206
document.addEventListener('click', (e) => {
203-
if (!e.target.closest('.checkbox-dropdown-container')) {
207+
if (!e.target.closest('.checkbox-dropdown')) {
204208
document.querySelectorAll('.checkbox-dropdown-menu.show').forEach(menu => {
205209
menu.classList.remove('show');
206-
const arrow = menu.previousElementSibling.querySelector('.dropdown-arrow');
210+
const trigger = menu.previousElementSibling;
211+
if (trigger) trigger.classList.remove('open');
212+
const arrow = trigger?.querySelector('.dropdown-arrow');
207213
if (arrow) arrow.style.transform = 'rotate(0deg)';
208214
});
209215
}

0 commit comments

Comments
 (0)