BottomSheet: fix esc key won't correctly close
All checks were successful
/ depoly (push) Successful in 1m18s
All checks were successful
/ depoly (push) Successful in 1m18s
This commit is contained in:
parent
481930264e
commit
5afaf21f4b
1 changed files with 10 additions and 2 deletions
|
@ -211,8 +211,9 @@ const BottomSheet: ParentComponent<BottomSheetProps> = (props) => {
|
|||
) => {
|
||||
if (event.target !== event.currentTarget) return;
|
||||
const rect = event.currentTarget.getBoundingClientRect();
|
||||
const isNotInDialog = event.clientY < rect.top ||
|
||||
event.clientY > (rect.bottom) ||
|
||||
const isNotInDialog =
|
||||
event.clientY < rect.top ||
|
||||
event.clientY > rect.bottom ||
|
||||
event.clientX < rect.left ||
|
||||
event.clientX > rect.right;
|
||||
if (isNotInDialog) {
|
||||
|
@ -220,6 +221,12 @@ const BottomSheet: ParentComponent<BottomSheetProps> = (props) => {
|
|||
}
|
||||
};
|
||||
|
||||
const onDialogCancel = (event: Event) => {
|
||||
event.preventDefault();
|
||||
|
||||
props.onClose?.("backdrop");
|
||||
};
|
||||
|
||||
return (
|
||||
<dialog
|
||||
class={`BottomSheet ${material.surface} ${props.class || ""}`}
|
||||
|
@ -227,6 +234,7 @@ const BottomSheet: ParentComponent<BottomSheetProps> = (props) => {
|
|||
["bottom"]: props.bottomUp,
|
||||
}}
|
||||
onClick={onDialogClick}
|
||||
onCancel={onDialogCancel}
|
||||
ref={element!}
|
||||
tabIndex={-1}
|
||||
role="presentation"
|
||||
|
|
Loading…
Reference in a new issue