Skip to content

Commit

Permalink
fix another collapse bug
Browse files Browse the repository at this point in the history
  • Loading branch information
glenwid committed May 4, 2021
1 parent a8fc6e7 commit b8bdfcb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
17 changes: 6 additions & 11 deletions src/components/CodeReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,15 @@ export const CodeReview: React.FC<CodeReviewProps> = ({
}
}

// 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
Expand Down
5 changes: 2 additions & 3 deletions src/stories/CodeReviewCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down

0 comments on commit b8bdfcb

Please sign in to comment.