如果事件阻止了,不关闭
This commit is contained in:
parent
3fb4114461
commit
c89994e64a
|
@ -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<DrawerProps, DrawerState> {
|
|||
@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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue