Skip to content

Commit

Permalink
Added global ESC handler to close popups
Browse files Browse the repository at this point in the history
  • Loading branch information
POPSuL committed Aug 30, 2021
1 parent fe36b8c commit 47c5144
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion web2/src/components/EditDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Can use used in tandem with ItemFormBase.js. See KeyForm.vue for example.
persistent
:transition="false"
:content-class="'item-dialog item-dialog--' + position"
@keydown.esc="close()"
>
<v-card>
<v-card-title class="headline">
Expand Down Expand Up @@ -81,6 +80,14 @@ export default {
};
},
beforeCreate() {
window.addEventListener('keydown', (ev) => {
if (ev.key === 'Escape' && this.dialog !== false) {
this.close();
}
});
},
watch: {
async dialog(val) {
this.$emit('input', val);
Expand Down

0 comments on commit 47c5144

Please sign in to comment.