From 5a5b9287c6f71637d3fe003d91fbfe595d4dedb8 Mon Sep 17 00:00:00 2001 From: Kabiru Mwenja Date: Mon, 12 May 2025 14:52:52 +0300 Subject: [PATCH] bug/63897 Missing target element "internalCheckbox" error when internal comments feature is disabled (#18856) On wp comment form submit end, safely toggle internal comment state https://community.openproject.org/wp/63897 When the Internal comments feature is disabled, the internalCommentCheckboxTarget does not exist, causing a warning from Stimulus; the InternalCommentController listens to form submit end events from the activities IndexController which manages comment form submission- it is then able to update the UI state on form close. E.g. Ensuring that the background color is reset https://github.com/opf/openproject/commit/e4270942f935c127bf322955933c7bb81b93192b --- .../activities-tab/internal-comment.controller.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.ts index 5193896780b..88c10b6095c 100644 --- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.ts +++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/internal-comment.controller.ts @@ -51,8 +51,12 @@ export default class InternalCommentController extends Controller { declare isInternalValue:boolean; + declare hasInternalCheckboxTarget:boolean; + onSubmitEnd(_event:CustomEvent):void { - this.toggleInternal(); + if (this.hasInternalCheckboxTarget) { + this.toggleInternal(); + } } toggleInternal():void {