aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Guyonvarch2025-05-03 14:58:32 +0200
committerJoris Guyonvarch2025-05-03 14:58:32 +0200
commitf6d91d1003b5d8b14f0c5c7e6dd0e40424916f29 (patch)
treee5bba26c7f3691e3ae0262937f18eaf5f0ea7cff
parent7cd82341088b7d3314d130c5df2840e273de7b27 (diff)
Prevent closing modal on input selectionmain
When selection ends outside of the modal, this could lead to closing the modal. Use `onmousedown` event instead, which takes the element at the start of the selection.
-rw-r--r--frontend/ts/src/ui/modal.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/frontend/ts/src/ui/modal.ts b/frontend/ts/src/ui/modal.ts
index 2d5e275..75b3ad9 100644
--- a/frontend/ts/src/ui/modal.ts
+++ b/frontend/ts/src/ui/modal.ts
@@ -18,7 +18,7 @@ export function view({ header, body, onClose, className, onmount, onunmount }: P
return h('div',
{ className: closingVar.map(isClosing => `g-Modal ${className ?? ''} ${isClosing ? 'g-Modal--Fade' : ''}`),
- onclick: onClose,
+ onmousedown: () => onClose(),
onmount: (element: Element) => {
document.addEventListener('keydown', onKeyDown)
if (onmount) onmount(element)
@@ -30,7 +30,7 @@ export function view({ header, body, onClose, className, onmount, onunmount }: P
},
h('div',
{ className: 'g-Modal__Content',
- onclick: (e: Event) => e.stopPropagation()
+ onmousedown: (e: Event) => e.stopPropagation()
},
h('div',
{ className: 'g-Modal__Header' },