cleanup event listener in MultiModal

This commit is contained in:
Jörn-Michael Miehe 2023-09-11 23:37:37 +00:00
parent b30e8095f9
commit 08972df4cc

View file

@ -23,10 +23,16 @@ export default class extends Vue {
public progress = false;
public image_src = "";
public created() {
window.addEventListener("keydown", (e) => {
if (e.key == "Escape") this.set_active(false);
});
private on_keydown(e: KeyboardEvent) {
if (e.key == "Escape") this.set_active(false);
}
public mounted(): void {
window.addEventListener("keydown", this.on_keydown);
}
public beforeUnmount(): void {
window.removeEventListener("keydown", this.on_keydown);
}
public set_active(state: boolean) {