diff --git a/src/webpage/contextmenu.ts b/src/webpage/contextmenu.ts index 17d6dd8..f1aaeb3 100644 --- a/src/webpage/contextmenu.ts +++ b/src/webpage/contextmenu.ts @@ -147,10 +147,8 @@ class Contextmenu { static setup() { Contextmenu.declareMenu(); document.addEventListener("click", (event) => { - while (Contextmenu.currentmenu) { - if (!Contextmenu.currentmenu.contains(event.target as Node)) { - Contextmenu.declareMenu(); - } + while (Contextmenu.currentmenu && !Contextmenu.currentmenu.contains(event.target as Node)) { + Contextmenu.declareMenu(); } }); }