Fix dialog closing when interacting with <select> child

https://discord.com/channels/1014774730907209781/1021695193499582494/1127653577360425042
'The.QCC: Embedding window. Switching between at end and at cursor closes the Embedding window'
This commit is contained in:
JeLuF 2023-07-09 21:18:07 +02:00
parent 6dfabb692d
commit b4c3c4c650

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)