Prevent escape closing Discord and BetterDiscord menus/modals at the same time

This commit is contained in:
Samuel Elliott 2018-04-08 19:54:48 +01:00
parent d2f7e6142f
commit 7adf63dfa8
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
1 changed files with 6 additions and 0 deletions

View File

@ -45,6 +45,10 @@
if (this.$refs.settings.activeIndex !== -1) this.$refs.settings.closeContent();
else this.active = false;
e.stopImmediatePropagation();
},
prevent(e) {
if (this.active && e.which === 27)
e.stopImmediatePropagation();
}
},
watch: {
@ -68,12 +72,14 @@
Events.on('update-check-end', e => this.updating = 1);
Events.on('updates-available', e => this.updating = 2);
window.addEventListener('keyup', this.keyupListener);
window.addEventListener('keydown', this.prevent, true);
const menuKeybind = Settings.getSetting('core', 'default', 'menu-keybind');
menuKeybind.on('keybind-activated', () => this.active = !this.active);
},
destroyed() {
window.removeEventListener('keyup', this.keyupListener);
window.removeEventListener('keydown', this.prevent);
}
}
</script>