优化判断逻辑

This commit is contained in:
rickcole 2020-06-01 14:19:26 +08:00
parent e1659bb033
commit e7ffe5659f
1 changed files with 9 additions and 9 deletions

View File

@ -115,15 +115,15 @@ export class Drawer extends React.Component<DrawerProps, DrawerState> {
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]')
) || target.matches(`.${ns}Drawer-overlay.in`); // 干脆过滤掉来自弹框里面的点击
this.isRootClosed = !!(
isLeftButton &&
closeOnOutside &&
target &&
this.modalDom &&
((!this.modalDom.contains(target) && !target.closest('[role=dialog]')) ||
(target.matches(`.${ns}Drawer-overlay`) &&
target.parentElement === this.modalDom))
); // 干脆过滤掉来自弹框里面的点击
}
@autobind