Fix modals hiding even if mousedown was triggered inside

This commit is contained in:
Giuseppe Criscione 2024-10-27 00:28:18 +02:00
parent ff6f5c5c57
commit b1274aff6f

View File

@ -25,9 +25,13 @@ export class Modal {
$("[data-dismiss]", element)?.addEventListener("click", () => this.hide());
let mousedownTriggered = false;
element.addEventListener("mousedown", () => (mousedownTriggered = true));
element.addEventListener("click", (event) => {
if (mousedownTriggered && event.target === element) {
element.addEventListener("mousedown", (event) => {
if (event.target !== element) {
mousedownTriggered = true;
}
});
element.addEventListener("click", () => {
if (!mousedownTriggered) {
this.hide();
}
mousedownTriggered = false;