chore: Add a fix for mouse up event in modal (#7950)
Co-authored-by: BikashSah999 <51731962+BikashSah999@users.noreply.github.com> Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
@@ -4,9 +4,13 @@
|
|||||||
v-if="show"
|
v-if="show"
|
||||||
:class="modalClassName"
|
:class="modalClassName"
|
||||||
transition="modal"
|
transition="modal"
|
||||||
@click="onBackDropClick"
|
@mousedown="handleMouseDown"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
:class="modalContainerClassName"
|
||||||
|
@mouse.stop
|
||||||
|
@mousedown="event => event.stopPropagation()"
|
||||||
>
|
>
|
||||||
<div :class="modalContainerClassName" @click.stop>
|
|
||||||
<woot-button
|
<woot-button
|
||||||
v-if="showCloseButton"
|
v-if="showCloseButton"
|
||||||
color-scheme="secondary"
|
color-scheme="secondary"
|
||||||
@@ -50,6 +54,11 @@ export default {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
mousedDownOnBackdrop: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
modalContainerClassName() {
|
modalContainerClassName() {
|
||||||
let className =
|
let className =
|
||||||
@@ -77,13 +86,22 @@ export default {
|
|||||||
this.onClose();
|
this.onClose();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.body.addEventListener('mouseup', this.onMouseUp);
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
document.body.removeEventListener('mouseup', this.onMouseUp);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleMouseDown() {
|
||||||
|
this.mousedDownOnBackdrop = true;
|
||||||
|
},
|
||||||
close() {
|
close() {
|
||||||
this.onClose();
|
this.onClose();
|
||||||
},
|
},
|
||||||
onBackDropClick() {
|
onMouseUp() {
|
||||||
if (this.closeOnBackdropClick) {
|
if (this.mousedDownOnBackdrop) {
|
||||||
|
this.mousedDownOnBackdrop = false;
|
||||||
this.onClose();
|
this.onClose();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user