From: Matthias Schmidt Date: Thu, 21 Jan 2021 15:46:49 +0000 (+0100) Subject: Fix reaction buttons X-Git-Tag: 5.4.0_Alpha_1~407 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6b1e53756a799a878bd1ee6a8215a1f5b5ae0fb9;p=GitHub%2FWoltLab%2FWCF.git Fix reaction buttons Close #3882 See 1dbe7a6f68083ca5e72cdaa62b46ad0bf2109bf0 --- diff --git a/ts/WoltLabSuite/Core/Ui/Reaction/Handler.ts b/ts/WoltLabSuite/Core/Ui/Reaction/Handler.ts index dff07fe58e..01ff388bba 100644 --- a/ts/WoltLabSuite/Core/Ui/Reaction/Handler.ts +++ b/ts/WoltLabSuite/Core/Ui/Reaction/Handler.ts @@ -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"); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js index 9de4a2373b..830cefe989 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Reaction/Handler.js @@ -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.