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"
|
||||
:class="modalClassName"
|
||||
transition="modal"
|
||||
@click="onBackDropClick"
|
||||
@mousedown="handleMouseDown"
|
||||
>
|
||||
<div :class="modalContainerClassName" @click.stop>
|
||||
<div
|
||||
:class="modalContainerClassName"
|
||||
@mouse.stop
|
||||
@mousedown="event => event.stopPropagation()"
|
||||
>
|
||||
<woot-button
|
||||
v-if="showCloseButton"
|
||||
color-scheme="secondary"
|
||||
@@ -50,6 +54,11 @@ export default {
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
mousedDownOnBackdrop: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
modalContainerClassName() {
|
||||
let className =
|
||||
@@ -77,13 +86,22 @@ export default {
|
||||
this.onClose();
|
||||
}
|
||||
});
|
||||
|
||||
document.body.addEventListener('mouseup', this.onMouseUp);
|
||||
},
|
||||
beforeDestroy() {
|
||||
document.body.removeEventListener('mouseup', this.onMouseUp);
|
||||
},
|
||||
methods: {
|
||||
handleMouseDown() {
|
||||
this.mousedDownOnBackdrop = true;
|
||||
},
|
||||
close() {
|
||||
this.onClose();
|
||||
},
|
||||
onBackDropClick() {
|
||||
if (this.closeOnBackdropClick) {
|
||||
onMouseUp() {
|
||||
if (this.mousedDownOnBackdrop) {
|
||||
this.mousedDownOnBackdrop = false;
|
||||
this.onClose();
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user