15 lines
494 B
TypeScript
15 lines
494 B
TypeScript
/** Native dialogs also receive clicks in their padding; only clicks beyond the bounds dismiss. */
|
|
export function isDialogBackdrop(
|
|
event: MouseEvent,
|
|
dialog: HTMLDialogElement | null | undefined
|
|
): boolean {
|
|
if (!dialog || event.target !== dialog) return false;
|
|
const rect = dialog.getBoundingClientRect();
|
|
return (
|
|
event.clientX < rect.left ||
|
|
event.clientX > rect.right ||
|
|
event.clientY < rect.top ||
|
|
event.clientY > rect.bottom
|
|
);
|
|
}
|