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); } }