From c89994e64a78372e555d0c6fe9091654877bd9ab Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Sat, 9 May 2020 09:54:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E4=BA=8B=E4=BB=B6=E9=98=BB?= =?UTF-8?q?=E6=AD=A2=E4=BA=86,=E4=B8=8D=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Drawer.tsx | 9 ++++++--- src/components/Modal.tsx | 2 +- src/components/ModalManager.ts | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/Drawer.tsx b/src/components/Drawer.tsx index 7d68ec64..a934ed04 100644 --- a/src/components/Drawer.tsx +++ b/src/components/Drawer.tsx @@ -24,7 +24,7 @@ export interface DrawerProps { bodyClassName?: string; size: any; overlay: boolean; - onHide: () => void; + onHide: (e: any) => void; closeOnEsc?: boolean; container: any; show?: boolean; @@ -109,10 +109,13 @@ export class Drawer extends React.Component { @autobind handleRootClick(e: MouseEvent) { const {classPrefix: ns, closeOnOutside, onHide, show} = this.props; - if ((e.target as HTMLElement).closest(`.${ns}Drawer-content`)) { + if ( + e.defaultPrevented || + (e.target as HTMLElement).closest(`.${ns}Drawer-content`) + ) { return; } - closeOnOutside && show && onHide && onHide(); + closeOnOutside && show && onHide && onHide(e); } render() { diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index 0afb4c9e..ecb17aec 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -20,7 +20,7 @@ export interface ModalProps { contentClassName?: string; size?: any; overlay?: boolean; - onHide: () => void; + onHide: (e: any) => void; closeOnEsc?: boolean; container?: any; show?: boolean; diff --git a/src/components/ModalManager.ts b/src/components/ModalManager.ts index cec0aa32..09506020 100644 --- a/src/components/ModalManager.ts +++ b/src/components/ModalManager.ts @@ -8,7 +8,7 @@ import keycode from 'keycode'; interface ModalComponent extends React.Component<{ - onHide: () => void; + onHide: (e: any) => void; disabled?: boolean; closeOnEsc?: boolean; }> {} @@ -44,6 +44,6 @@ function handleWindowKeyDown(e: Event) { } const {disabled, closeOnEsc} = modal.props; if (closeOnEsc && !disabled) { - modal.props.onHide(); + modal.props.onHide(e); } }