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,8 +215,12 @@ class Dialog {
this.$el.querySelectorAll("[close]").forEach((el) => { this.$el.querySelectorAll("[close]").forEach((el) => {
el.addEventListener("click", (e) => this.hide()); el.addEventListener("click", (e) => this.hide());
}); });
this.$el.querySelectorAll("[role=\"textbox\"]").forEach((el) => { this.$el.querySelectorAll('[role="textbox"]').forEach((el) => {
el.addEventListener("click", (e) => this.hide()); el.addEventListener("keypress", (e) => {
if (e.key == "Escape") {
this.hide();
}
});
}); });
this.$autoFocus = this.$el.querySelector("[autofocus]"); this.$autoFocus = this.$el.querySelector("[autofocus]");
} }