This commit is contained in:
Tomas Dvorak
2025-05-30 12:09:33 +02:00
parent a7ee077115
commit 58c899a6bf
+21 -21
View File
@@ -206,6 +206,11 @@
z-index: 9999; z-index: 9999;
padding: 2rem; padding: 2rem;
overflow-y: auto; overflow-y: auto;
pointer-events: none;
}
#iconPickerModal.show {
pointer-events: auto;
} }
#iconPickerContainer { #iconPickerContainer {
@@ -2427,32 +2432,21 @@ function initIconPicker() {
let isModalOpen = false; let isModalOpen = false;
// Simple show/hide functions // Simple show/hide functions
const showModal = () => { const toggleModal = () => {
if (isModalOpen) return; isModalOpen = !isModalOpen;
isModalOpen = true; document.body.style.overflow = isModalOpen ? 'hidden' : '';
document.body.style.overflow = 'hidden'; iconPickerModal.style.display = isModalOpen ? 'block' : 'none';
iconPickerModal.style.display = 'block';
if (iconSearch) { if (isModalOpen && iconSearch) {
setTimeout(() => iconSearch.focus(), 50); setTimeout(() => iconSearch.focus(), 50);
} }
}; };
const hideModal = () => {
if (!isModalOpen) return;
isModalOpen = false;
document.body.style.overflow = '';
iconPickerModal.style.display = 'none';
};
// Toggle modal on icon input click // Toggle modal on icon input click
iconInput.addEventListener('click', (e) => { iconInput.addEventListener('click', (e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
if (isModalOpen) { toggleModal();
hideModal();
} else {
showModal();
}
}); });
// Close modal handlers // Close modal handlers
@@ -2460,14 +2454,18 @@ function initIconPicker() {
closeButton.addEventListener('click', (e) => { closeButton.addEventListener('click', (e) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
hideModal(); isModalOpen = false;
document.body.style.overflow = '';
iconPickerModal.style.display = 'none';
}); });
} }
// Close when clicking outside the modal content // Close when clicking outside the modal content
iconPickerModal.addEventListener('click', (e) => { iconPickerModal.addEventListener('click', (e) => {
if (e.target === iconPickerModal) { if (e.target === iconPickerModal) {
hideModal(); isModalOpen = false;
document.body.style.overflow = '';
iconPickerModal.style.display = 'none';
} }
}); });
@@ -2491,7 +2489,9 @@ function initIconPicker() {
// Close on Escape // Close on Escape
document.addEventListener('keydown', (e) => { document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && isModalOpen) { if (e.key === 'Escape' && isModalOpen) {
hideModal(); isModalOpen = false;
document.body.style.overflow = '';
iconPickerModal.style.display = 'none';
} }
}); });
} }