From f9f49198fafb3920818ec117025d827428398c2c Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Wed, 26 Oct 2022 11:29:58 +0200 Subject: [PATCH] Prevent error when commenting via an answer page --- app/javascript/retrospring/features/answerbox/comment/new.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/javascript/retrospring/features/answerbox/comment/new.ts b/app/javascript/retrospring/features/answerbox/comment/new.ts index e97c497b..48e6ee21 100644 --- a/app/javascript/retrospring/features/answerbox/comment/new.ts +++ b/app/javascript/retrospring/features/answerbox/comment/new.ts @@ -38,7 +38,10 @@ export function commentCreateHandler(event: KeyboardEvent): boolean { if (data.success) { document.querySelector(`#ab-comments-${id}`).innerHTML = data.render; - document.querySelector(`#ab-comment-count-${id}`).innerHTML = data.count; + const commentCount = document.getElementById(`#ab-comment-count-${id}`); + if (commentCount) { + commentCount.innerHTML = data.count; + } input.value = ''; counter.innerHTML = String(160);