close text modal on escape press

This commit is contained in:
MoPaMo 2021-06-16 07:15:03 +02:00
parent 8809ea6667
commit f71b025db6

View file

@ -215,9 +215,13 @@ class Dialog {
this.$el.querySelectorAll("[close]").forEach((el) => {
el.addEventListener("click", (e) => this.hide());
});
this.$el.querySelectorAll("[role=\"textbox\"]").forEach((el) => {
el.addEventListener("click", (e) => this.hide());
this.$el.querySelectorAll('[role="textbox"]').forEach((el) => {
el.addEventListener("keypress", (e) => {
if (e.key == "Escape") {
this.hide();
}
});
});
this.$autoFocus = this.$el.querySelector("[autofocus]");
}