function handleClick()

in src/lib/attachments/click-outside.ts [5:30]


		function handleClick(event: MouseEvent) {
			if (window.getSelection()?.toString()) {
				// Don't close if text is selected
				return;
			}

			// For dialog elements, check if click was on the backdrop
			if (node instanceof HTMLDialogElement) {
				const rect = node.getBoundingClientRect();
				const isInDialog =
					event.clientX >= rect.left &&
					event.clientX <= rect.right &&
					event.clientY >= rect.top &&
					event.clientY <= rect.bottom;

				if (!isInDialog) {
					callback();
					return;
				}
			}

			// For non-dialog elements, use the standard contains check
			if (!node.contains(event.target as Node) && !event.defaultPrevented) {
				callback();
			}
		}