diff --git a/src/material/BottomSheet.tsx b/src/material/BottomSheet.tsx index 8a1dd62..4ae9686 100644 --- a/src/material/BottomSheet.tsx +++ b/src/material/BottomSheet.tsx @@ -209,13 +209,13 @@ const BottomSheet: ParentComponent = (props) => { const onDialogClick = ( event: MouseEvent & { currentTarget: HTMLDialogElement }, ) => { + if (event.target !== event.currentTarget) return; const rect = event.currentTarget.getBoundingClientRect(); - const isInDialog = - rect.top <= event.clientY && - event.clientY <= rect.top + rect.height && - rect.left <= event.clientX && - event.clientX <= rect.left + rect.width; - if (!isInDialog) { + const isNotInDialog = event.clientY < rect.top || + event.clientY > (rect.bottom) || + event.clientX < rect.left || + event.clientX > rect.right; + if (isNotInDialog) { props.onClose?.("backdrop"); } };