Merge pull request #1396 from JeLuF/dlgclose

Fix dialog closing when interacting with <select> child
This commit is contained in:
cmdr2 2023-07-13 13:00:07 +05:30 committed by GitHub
commit 837ad5b68c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1074,6 +1074,12 @@ async function deleteKeys(keyToDelete) {
function modalDialogCloseOnBackdropClick(dialog) {
dialog.addEventListener('mousedown', function (event) {
// Firefox creates an event with clientX|Y = 0|0 when choosing an <option>.
// Test whether the element interacted with is a child of the dialog, but not the
// dialog itself (the backdrop would be a part of the dialog)
if (dialog.contains(event.target) && dialog != event.target) {
return
}
var rect = dialog.getBoundingClientRect()
var isInDialog=(rect.top <= event.clientY && event.clientY <= rect.top + rect.height
&& rect.left <= event.clientX && event.clientX <= rect.left + rect.width)