From f965bb4002139697da13079dd07583849ee863c8 Mon Sep 17 00:00:00 2001 From: thislight Date: Thu, 7 Nov 2024 16:17:42 +0800 Subject: [PATCH] BottomSheet: fix click inner select trigger close --- src/material/BottomSheet.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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"); } };