Is there a reason why the key-event for "escape" just works if the user first clicks inside the modal? I think it would be better if you have a global key event listener which closes you the latest modal.
mounted() {
VuedalsBus.$on('opened', (modal) => {
if (modal.options.escapable) {
document.addEventListener('keydown', function dismissModal(event) {
if (event.keyCode === 27) {
VuedalsBus.$emit('close');
document.removeEventListener('keydown', dismissModal, true);
}
}, true);
}
});
},
Is there a reason why the key-event for "escape" just works if the user first clicks inside the modal? I think it would be better if you have a global key event listener which closes you the latest modal.
Something like: