Skip to content

Commit 1040fe8

Browse files
committed
Refactor mobile dropdown script in footer.html
- Removed custom JavaScript logic that overrode Bootstrap's default dropdown behavior on mobile devices, including event listeners and manual dropdown management. - Retained only the desktop dropdown positioning fix, relying on Bootstrap 5's native handling for mobile dropdowns. Signed-off-by: Leonid Petrov <lenia.petrov@gmail.com>
1 parent c38640e commit 1040fe8

File tree

1 file changed

+2
-33
lines changed

1 file changed

+2
-33
lines changed

_includes/footer.html

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -133,39 +133,8 @@
133133
<!-- Dropdown enhancements for mobile -->
134134
<script>
135135
document.addEventListener('DOMContentLoaded', function() {
136-
// Only apply to mobile
137-
if (window.innerWidth <= 767) {
138-
const dropdownToggles = document.querySelectorAll('.navbar-nav .dropdown-toggle');
139-
140-
dropdownToggles.forEach(toggle => {
141-
// Override Bootstrap's default dropdown behavior on mobile
142-
toggle.addEventListener('click', function(e) {
143-
if (window.innerWidth <= 767) {
144-
e.preventDefault();
145-
e.stopPropagation();
146-
147-
const dropdownMenu = this.nextElementSibling;
148-
const bsDropdown = bootstrap.Dropdown.getInstance(this);
149-
150-
// Close other dropdowns
151-
dropdownToggles.forEach(otherToggle => {
152-
if (otherToggle !== this) {
153-
const otherMenu = otherToggle.nextElementSibling;
154-
const otherBsDropdown = bootstrap.Dropdown.getInstance(otherToggle);
155-
if (otherBsDropdown) {
156-
otherBsDropdown.hide();
157-
}
158-
}
159-
});
160-
161-
// Toggle current dropdown
162-
if (bsDropdown) {
163-
bsDropdown.toggle();
164-
}
165-
}
166-
});
167-
});
168-
}
136+
// Remove the mobile click override that was breaking functionality
137+
// Bootstrap 5 handles mobile dropdowns well by default
169138

170139
// Fix dropdown positioning on desktop to prevent overflow and ensure consistency
171140
const dropdowns = document.querySelectorAll('.navbar-nav .dropdown');

0 commit comments

Comments
 (0)