diff --git a/src/components/Drawer.tsx b/src/components/Drawer.tsx index 7814246bf..7da980b37 100644 --- a/src/components/Drawer.tsx +++ b/src/components/Drawer.tsx @@ -111,20 +111,19 @@ export class Drawer extends React.Component { @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