From 6317ba542a21eafc02d833c3b45928c373acc6fe Mon Sep 17 00:00:00 2001 From: Magnum Date: Mon, 6 Mar 2017 13:34:48 +0100 Subject: [PATCH] do not trigger on key events when modal is not visible fix-key-event --- components/modal.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/modal.vue b/components/modal.vue index c7b421cde77..d8cfcfef577 100755 --- a/components/modal.vue +++ b/components/modal.vue @@ -35,7 +35,8 @@ export default { data() { return { animateBackdrop: false, - animateModal: false + animateModal: false, + visible: false }; }, props: { @@ -58,6 +59,7 @@ export default { }, methods: { show() { + this.visible = true; this.$el.style.display = 'block'; this._body = document.querySelector('body'); const _this = this; @@ -72,6 +74,7 @@ export default { }, 0); }, hide() { + this.visible = false; const _this = this; // first animate modal out this.animateModal = false; @@ -93,6 +96,11 @@ export default { } }, pressedButton(e) { + if( !this.visible ) { + // if not visible don't do anything + return; + } + // support for esc key press const key = e.which || e.keyCode; if (key === 27) { // 27 is esc