Skip to content

do not trigger on key events when modal is not visible #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion components/modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export default {
data() {
return {
animateBackdrop: false,
animateModal: false
animateModal: false,
visible: false
};
},
props: {
Expand All @@ -58,6 +59,7 @@ export default {
},
methods: {
show() {
this.visible = true;
this.$el.style.display = 'block';
this._body = document.querySelector('body');
const _this = this;
Expand All @@ -72,6 +74,7 @@ export default {
}, 0);
},
hide() {
this.visible = false;
const _this = this;
// first animate modal out
this.animateModal = false;
Expand All @@ -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
Expand Down