Fix reaction buttons
authorMatthias Schmidt <gravatronics@live.com>
Thu, 21 Jan 2021 15:46:49 +0000 (16:46 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 21 Jan 2021 15:46:49 +0000 (16:46 +0100)
Close #3882

See 1dbe7a6f68083ca5e72cdaa62b46ad0bf2109bf0

ts/WoltLabSuite/Core/Ui/Reaction/Handler.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js

index dff07fe58ea4c139d8f63df61d09bcce5b18e5b7..01ff388bba8c885e3d52b90fcc9b6bcb2762a98c 100644 (file)
@@ -181,14 +181,14 @@ class UiReactionHandler {
   }
 
   protected _markReactionAsActive(): void {
-    let reactionTypeID = 0;
+    let reactionTypeID: number | null = null;
     this._objects.get(this._popoverCurrentObjectId)!.forEach((element) => {
       if (element.reactButton !== null) {
         reactionTypeID = ~~element.reactButton.dataset.reactionTypeId!;
       }
     });
 
-    if (!reactionTypeID) {
+    if (reactionTypeID === null) {
       throw new Error("Unable to find react button for current popover.");
     }
 
@@ -199,7 +199,7 @@ class UiReactionHandler {
     const scrollableContainer = popover.querySelector(".reactionPopoverContent") as HTMLElement;
     if (reactionTypeID) {
       const reactionTypeButton = popover.querySelector(
-        `.reactionTypeButton[data-reaction-type-id="${reactionTypeID}"]`,
+        `.reactionTypeButton[data-reaction-type-id="${reactionTypeID!}"]`,
       ) as HTMLElement;
       reactionTypeButton.classList.add("active");
 
index 9de4a2373bc44bb49b8d7382937b4bc3e5aa150e..830cefe989c102601990b0ad348f04fcfd676aa3 100644 (file)
@@ -115,13 +115,13 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Core", "../../Dom/Ch
             });
         }
         _markReactionAsActive() {
-            let reactionTypeID = 0;
+            let reactionTypeID = null;
             this._objects.get(this._popoverCurrentObjectId).forEach((element) => {
                 if (element.reactButton !== null) {
                     reactionTypeID = ~~element.reactButton.dataset.reactionTypeId;
                 }
             });
-            if (!reactionTypeID) {
+            if (reactionTypeID === null) {
                 throw new Error("Unable to find react button for current popover.");
             }
             //  Clear the old active state.