BottomSheet: fix click inner select trigger close
All checks were successful
/ depoly (push) Successful in 1m17s

This commit is contained in:
thislight 2024-11-07 16:17:42 +08:00
parent f15a52b3db
commit f965bb4002
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E

View file

@ -209,13 +209,13 @@ const BottomSheet: ParentComponent<BottomSheetProps> = (props) => {
const onDialogClick = ( const onDialogClick = (
event: MouseEvent & { currentTarget: HTMLDialogElement }, event: MouseEvent & { currentTarget: HTMLDialogElement },
) => { ) => {
if (event.target !== event.currentTarget) return;
const rect = event.currentTarget.getBoundingClientRect(); const rect = event.currentTarget.getBoundingClientRect();
const isInDialog = const isNotInDialog = event.clientY < rect.top ||
rect.top <= event.clientY && event.clientY > (rect.bottom) ||
event.clientY <= rect.top + rect.height && event.clientX < rect.left ||
rect.left <= event.clientX && event.clientX > rect.right;
event.clientX <= rect.left + rect.width; if (isNotInDialog) {
if (!isInDialog) {
props.onClose?.("backdrop"); props.onClose?.("backdrop");
} }
}; };