From 08972df4cc93413396258143036480dbd9734728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Mon, 11 Sep 2023 23:37:37 +0000 Subject: [PATCH] cleanup event listener in MultiModal --- ui/src/components/calendar/MultiModal.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ui/src/components/calendar/MultiModal.vue b/ui/src/components/calendar/MultiModal.vue index a3825dd..81269ec 100644 --- a/ui/src/components/calendar/MultiModal.vue +++ b/ui/src/components/calendar/MultiModal.vue @@ -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) {