From b8bdfcb309aad2ae56bb78c6e3ec6db961fc8217 Mon Sep 17 00:00:00 2001 From: Glen Wider Date: Tue, 4 May 2021 16:04:19 +0200 Subject: [PATCH] fix another collapse bug --- src/components/CodeReview.tsx | 17 ++++++----------- src/stories/CodeReviewCard.stories.tsx | 5 ++--- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/components/CodeReview.tsx b/src/components/CodeReview.tsx index d538060..4a277ff 100644 --- a/src/components/CodeReview.tsx +++ b/src/components/CodeReview.tsx @@ -81,20 +81,15 @@ export const CodeReview: React.FC = ({ } } + // processes possible change in commentViewer numbers const setupState = (state: State): State => { - // check the amount of values in the current state - // and check if new values need to get pushed in case of a new comment - const count: number = linesWithCommentViewer.length - const dif: number = count - state.length + let newState: State = [] - // add values - // +1 to add a value for the result viewer - if (state.length !== count + 1) { - for (let i = 0; i < dif + 1; i++) { - state.push(false) - } + // length +1 to add a value for the result viewer + for(let i = 0; i < linesWithCommentViewer.length + 1; i++) { + newState = [...newState, false] } - return state + return newState } // array containing all unique lines that contain comments or infos diff --git a/src/stories/CodeReviewCard.stories.tsx b/src/stories/CodeReviewCard.stories.tsx index aebeb9e..2359346 100644 --- a/src/stories/CodeReviewCard.stories.tsx +++ b/src/stories/CodeReviewCard.stories.tsx @@ -173,9 +173,8 @@ const handleCommentDeleted = ( element => element === comment ) if (index > -1) { - const newContainer = story.args.reviewProps.commentContainer - newContainer.splice(index, 1) - story.args.reviewProps.commentContainer = newContainer + customCommentContainer.splice(index, 1) + story.args.reviewProps.commentContainer = customCommentContainer forceReRender() } }