Skip to content

Commit 5626627

Browse files
luckyCaoisland205
authored andcommitted
Dialog: Fix close bug (ElemeFE#15000) (ElemeFE#15544)
1 parent 0bb4121 commit 5626627

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

packages/dialog/src/component.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
name="dialog-fade"
44
@after-enter="afterEnter"
55
@after-leave="afterLeave">
6-
<div class="el-dialog__wrapper" v-show="visible" @click.self="handleWrapperClick">
6+
<div class="el-dialog__wrapper" v-show="visible" @click.self="handleWrapperClick" @mouseup="handleMouseup">
77
<div
88
role="dialog"
99
aria-modal="true"
1010
:aria-label="title || 'dialog'"
1111
class="el-dialog"
1212
:class="[{ 'is-fullscreen': fullscreen, 'el-dialog--center': center }, customClass]"
1313
ref="dialog"
14-
:style="style">
14+
:style="style"
15+
@mousedown="handleMousedown">
1516
<div class="el-dialog__header">
1617
<slot name="title">
1718
<span class="el-dialog__title">{{ title }}</span>
@@ -39,6 +40,8 @@
3940
import Migrating from 'element-ui/src/mixins/migrating';
4041
import emitter from 'element-ui/src/mixins/emitter';
4142
43+
let dialogMouseDown = false;
44+
4245
export default {
4346
name: 'ElDialog',
4447
@@ -152,9 +155,19 @@
152155
};
153156
},
154157
handleWrapperClick() {
155-
if (!this.closeOnClickModal) return;
158+
if (!this.closeOnClickModal || dialogMouseDown) return;
156159
this.handleClose();
157160
},
161+
handleMousedown() {
162+
dialogMouseDown = true;
163+
},
164+
handleMouseup() {
165+
if (dialogMouseDown) {
166+
this.$nextTick(_ => {
167+
dialogMouseDown = false;
168+
});
169+
}
170+
},
158171
handleClose() {
159172
if (typeof this.beforeClose === 'function') {
160173
this.beforeClose(this.hide);

0 commit comments

Comments
 (0)