Files
builder-prototype/static/js/fix-dropdown.js
Nathan Schneider 521c782c42 Initial commit
2025-03-23 21:44:39 -06:00

26 lines
977 B
JavaScript

// Make sure the dropdown works correctly
document.addEventListener('DOMContentLoaded', function() {
const exportBtn = document.getElementById('export-btn');
const dropdownMenu = document.querySelector('.dropdown-menu');
if (exportBtn && dropdownMenu) {
// Force clear any previous event listeners
const newExportBtn = exportBtn.cloneNode(true);
exportBtn.parentNode.replaceChild(newExportBtn, exportBtn);
// Add event listener to the new button
newExportBtn.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
dropdownMenu.style.display = dropdownMenu.style.display === 'block' ? 'none' : 'block';
});
// Close dropdown when clicking elsewhere
document.addEventListener('click', function(e) {
if (newExportBtn && \!newExportBtn.contains(e.target) && dropdownMenu && \!dropdownMenu.contains(e.target)) {
dropdownMenu.style.display = 'none';
}
});
}
});