Skip to content

Commit d409e53

Browse files
authored
Merge pull request bootstrap-vue#133 from Magnum5234/fix-key-event
do not trigger on key events when modal is not visible
2 parents 8dcb218 + 6317ba5 commit d409e53

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

components/modal.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export default {
3535
data() {
3636
return {
3737
animateBackdrop: false,
38-
animateModal: false
38+
animateModal: false,
39+
visible: false
3940
};
4041
},
4142
props: {
@@ -58,6 +59,7 @@ export default {
5859
},
5960
methods: {
6061
show() {
62+
this.visible = true;
6163
this.$el.style.display = 'block';
6264
this._body = document.querySelector('body');
6365
const _this = this;
@@ -72,6 +74,7 @@ export default {
7274
}, 0);
7375
},
7476
hide() {
77+
this.visible = false;
7578
const _this = this;
7679
// first animate modal out
7780
this.animateModal = false;
@@ -93,6 +96,11 @@ export default {
9396
}
9497
},
9598
pressedButton(e) {
99+
if( !this.visible ) {
100+
// if not visible don't do anything
101+
return;
102+
}
103+
96104
// support for esc key press
97105
const key = e.which || e.keyCode;
98106
if (key === 27) { // 27 is esc

0 commit comments

Comments
 (0)