Merge pull request #637 from RickCole21/master

Drawer 有 overlay 时,配置 closeOnOutside 失效
This commit is contained in:
liaoxuezhi 2020-06-01 14:20:22 +08:00 committed by GitHub
commit f6e7259287
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,20 +111,19 @@ export class Drawer extends React.Component<DrawerProps, DrawerState> {
@autobind
handleRootClickCapture(e: MouseEvent) {
const target = e.target as HTMLElement;
const closeOnOutside = this.props.closeOnOutside;
const {closeOnOutside, classPrefix: ns} = this.props;
const isLeftButton =
(e.button === 1 && window.event !== null) || e.button === 0;
this.isRootClosed = !!(
(
isLeftButton &&
closeOnOutside &&
target &&
this.modalDom &&
!this.modalDom.contains(target) &&
!target.closest('[role=dialog]')
) // 干脆过滤掉来自弹框里面的点击
);
isLeftButton &&
closeOnOutside &&
target &&
this.modalDom &&
((!this.modalDom.contains(target) && !target.closest('[role=dialog]')) ||
(target.matches(`.${ns}Drawer-overlay`) &&
target.parentElement === this.modalDom))
); // 干脆过滤掉来自弹框里面的点击
}
@autobind