Incorrect access of an element that is not always present
authorAlexander Ebert <ebert@woltlab.com>
Fri, 25 Jun 2021 14:27:40 +0000 (16:27 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 25 Jun 2021 14:27:40 +0000 (16:27 +0200)
ts/WoltLabSuite/Core/Ui/Message/Quote.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Message/Quote.js

index c60e5fc0d9a72e26b6c2f9a1acb0c6d71784ff4f..551fd9b3f17e501394ff0cda32d9916de0d5fdf4 100644 (file)
@@ -483,8 +483,8 @@ export class UiMessageQuote implements AjaxCallbackObject {
     }
 
     // close navigation on mobile
-    const navigationList = listItem.closest(".buttonGroupNavigation") as HTMLUListElement;
-    if (navigationList.classList.contains("jsMobileButtonGroupNavigation")) {
+    const navigationList = listItem.closest(".buttonGroupNavigation") as HTMLUListElement | null;
+    if (navigationList && navigationList.classList.contains("jsMobileButtonGroupNavigation")) {
       const dropDownLabel = navigationList.querySelector(".dropdownLabel") as HTMLElement;
       dropDownLabel.click();
     }
index 917194b59933812ce50448d5618a62847ae55a96..c3daffa6b4f781a4f267c727e1635f7875e83f6f 100644 (file)
@@ -358,7 +358,7 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Core", "../../Event/
             }
             // close navigation on mobile
             const navigationList = listItem.closest(".buttonGroupNavigation");
-            if (navigationList.classList.contains("jsMobileButtonGroupNavigation")) {
+            if (navigationList && navigationList.classList.contains("jsMobileButtonGroupNavigation")) {
                 const dropDownLabel = navigationList.querySelector(".dropdownLabel");
                 dropDownLabel.click();
             }