Merge pull request #579 from RickCole21/master

drawer overlay逻辑优化
This commit is contained in:
liaoxuezhi 2020-05-08 20:45:50 +08:00 committed by GitHub
commit 7bacf2df39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -115,6 +115,8 @@
}
&.#{$ns}Drawer--noOverlay {
pointer-events: none;
.#{$ns}Drawer-close svg {
margin-top: px2rem(2px);
width: px2rem(20px);

View File

@ -69,12 +69,14 @@ export class Drawer extends React.Component<DrawerProps, DrawerState> {
if (this.props.show) {
this.handleEntered();
}
document.body.addEventListener('click', this.handleRootClick);
}
componentWillUnmount() {
if (this.props.show) {
this.handleExited();
}
document.body.removeEventListener('click', this.handleRootClick);
}
contentRef = (ref: any) => (this.contentDom = ref);
@ -105,7 +107,7 @@ export class Drawer extends React.Component<DrawerProps, DrawerState> {
};
@autobind
handleWidgetClick(e: React.MouseEvent) {
handleRootClick(e: MouseEvent) {
const {classPrefix: ns, closeOnOutside, onHide} = this.props;
if ((e.target as HTMLElement).closest(`.${ns}Drawer-content`)) {
return;
@ -159,7 +161,7 @@ export class Drawer extends React.Component<DrawerProps, DrawerState> {
},
className
)}
onClick={this.handleWidgetClick} // 其实不需要插件,直接写逻辑吧
// onClick={this.handleWidgetClick} // 其实不需要插件,直接写逻辑吧
>
{overlay ? (
<div

View File

@ -141,6 +141,11 @@ export default class Drawer extends React.Component<DrawerProps, object> {
handleSelfClose() {
const {onClose, store} = this.props;
// 如果有子弹框,那么就先不隐藏自己
if (store.dialogOpen !== false || store.drawerOpen !== false) {
return;
}
// clear error
store.updateMessage();
onClose();