WebUI: Close only focused modal

This commit is contained in:
Stiliyan Tonev (Bark) 2025-06-26 09:45:15 +03:00
parent 52bf8fb8d0
commit db341a2e6e

View file

@ -1782,11 +1782,12 @@ window.addEventListener("DOMContentLoaded", (event) => {
if (modalInstances.length <= 0) if (modalInstances.length <= 0)
return; return;
// MochaUI.currentModal does not update after a modal is closed // MochaUI.currentModal does not update after a modal is closed
// use `timestamp` for sequential closing const focusedModal = modalInstances.find((modal) => {
const latestModal = modalInstances.reduce((prev, curr) => { return modal.windowEl.hasClass("isFocused");
return (prev.timestamp > curr.timestamp) ? prev : curr;
}); });
latestModal.close(); if (!focusedModal)
return;
focusedModal.close();
break; break;
} }
} }