Merge branch 'master' into budi-9018-searching-budidb-column-headings-in-the-data-tab-breaks-grid

This commit is contained in:
Sam Rose 2025-02-05 12:18:55 +00:00 committed by GitHub
commit dc59a08363
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 1 deletions

View File

@ -34,7 +34,7 @@ let candidateTarget: HTMLElement | undefined
// Processes a "click outside" event and invokes callbacks if our source element
// is valid
const handleClick = (e: MouseEvent) => {
const target = e.target as HTMLElement
const target = (e.target || e.relatedTarget) as HTMLElement
// Ignore click if this is an ignored class
if (target.closest('[data-ignore-click-outside="true"]')) {
@ -91,9 +91,19 @@ const handleMouseDown = (e: MouseEvent) => {
document.addEventListener("click", handleMouseUp, true)
}
// Handle iframe clicks by detecting a loss of focus on the main window
const handleBlur = () => {
if (document.activeElement?.tagName === "IFRAME") {
handleClick(
new MouseEvent("click", { relatedTarget: document.activeElement })
)
}
}
// Global singleton listeners for our events
document.addEventListener("mousedown", handleMouseDown)
document.addEventListener("contextmenu", handleClick)
window.addEventListener("blur", handleBlur)
/**
* Adds or updates a click handler