✨ Press Escape to close modal, Enter to return. Fixes #539
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
type="text"
|
||||
v-model="name"
|
||||
:placeholder="$t('my_new_collection')"
|
||||
@keyup.enter="addNewCollection"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
type="text"
|
||||
v-model="name"
|
||||
:placeholder="$t('my_new_folder')"
|
||||
@keyup.enter="addNewFolder"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -142,6 +142,15 @@ export default {
|
||||
return this.$store.state.postwoman.collections;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this._keyListener = function(e) {
|
||||
if (e.key === "Escape") {
|
||||
e.preventDefault();
|
||||
this.showModalAdd = this.showModalEdit = this.showModalImportExport = this.showModalAddFolder = this.showModalEditFolder = this.showModalEditRequest = false;
|
||||
}
|
||||
};
|
||||
document.addEventListener("keydown", this._keyListener.bind(this));
|
||||
},
|
||||
methods: {
|
||||
displayModalAdd(shouldDisplay) {
|
||||
this.showModalAdd = shouldDisplay;
|
||||
@@ -216,6 +225,9 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
document.removeEventListener("keydown", this._keyListener);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -801,6 +801,14 @@ export default {
|
||||
});
|
||||
}, 15000);
|
||||
}
|
||||
|
||||
this._keyListener = function(e) {
|
||||
if (e.key === "Escape") {
|
||||
e.preventDefault();
|
||||
this.showExtensions = this.showShortcuts = this.showSupport = false;
|
||||
}
|
||||
};
|
||||
document.addEventListener("keydown", this._keyListener.bind(this));
|
||||
})();
|
||||
|
||||
window.addEventListener("scroll", event => {
|
||||
@@ -841,6 +849,10 @@ export default {
|
||||
availableLocales() {
|
||||
return this.$i18n.locales.filter(i => i.code !== this.$i18n.locale);
|
||||
}
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
document.removeEventListener("keydown", this._keyListener);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -2856,6 +2856,10 @@ export default {
|
||||
} else if (e.key === "j" && (e.ctrlKey || e.metaKey)) {
|
||||
e.preventDefault();
|
||||
this.$refs.clearAll.click();
|
||||
} else if (e.key === "Escape") {
|
||||
e.preventDefault();
|
||||
this.showModal = this.showTokenList = this.showTokenRequestList = this.showRequestModal = false;
|
||||
this.isHidden = true;
|
||||
}
|
||||
};
|
||||
document.addEventListener("keydown", this._keyListener.bind(this));
|
||||
|
||||
Reference in New Issue
Block a user