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;
|
if (event.target !== event.currentTarget) return;
|
||||||
const rect = event.currentTarget.getBoundingClientRect();
|
const rect = event.currentTarget.getBoundingClientRect();
|
||||||
const isNotInDialog = event.clientY < rect.top ||
|
const isNotInDialog =
|
||||||
event.clientY > (rect.bottom) ||
|
event.clientY < rect.top ||
|
||||||
|
event.clientY > rect.bottom ||
|
||||||
event.clientX < rect.left ||
|
event.clientX < rect.left ||
|
||||||
event.clientX > rect.right;
|
event.clientX > rect.right;
|
||||||
if (isNotInDialog) {
|
if (isNotInDialog) {
|
||||||
|
@ -220,6 +221,12 @@ const BottomSheet: ParentComponent<BottomSheetProps> = (props) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onDialogCancel = (event: Event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
props.onClose?.("backdrop");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dialog
|
<dialog
|
||||||
class={`BottomSheet ${material.surface} ${props.class || ""}`}
|
class={`BottomSheet ${material.surface} ${props.class || ""}`}
|
||||||
|
@ -227,6 +234,7 @@ const BottomSheet: ParentComponent<BottomSheetProps> = (props) => {
|
||||||
["bottom"]: props.bottomUp,
|
["bottom"]: props.bottomUp,
|
||||||
}}
|
}}
|
||||||
onClick={onDialogClick}
|
onClick={onDialogClick}
|
||||||
|
onCancel={onDialogCancel}
|
||||||
ref={element!}
|
ref={element!}
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
role="presentation"
|
role="presentation"
|
||||||
|
|
Loading…
Reference in a new issue