Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 827a9cd

Browse files
authored
Fix bug where table cells wrap when cell collapsed (#2111)
1 parent 7ebfbcf commit 827a9cd

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Classes/Issues/Comments/Tables/IssueCommentTableCell.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@ UICollectionViewDelegateFlowLayout {
5252

5353
override func layoutSubviews() {
5454
super.layoutSubviews()
55-
collectionView.frame = contentView.bounds
55+
if let model = self.model {
56+
collectionView.frame = CGRect(
57+
x: 0,
58+
y: 0,
59+
width: bounds.width,
60+
height: model.size.height
61+
)
62+
}
5663
}
5764

5865
// MARK: ListBindable

Classes/Issues/Comments/Tables/IssueCommentTableModel.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,17 @@ final class IssueCommentTableModel: NSObject, ListDiffable {
3535

3636
let columns: [Column]
3737
let rowHeights: [CGFloat]
38+
let size: CGSize
3839

3940
init(columns: [Column], rowHeights: [CGFloat]) {
4041
self.columns = columns
4142
self.rowHeights = rowHeights
43+
44+
let inset = IssueCommentTableCell.inset
45+
self.size = CGSize(
46+
width: columns.reduce(0) { $0 + $1.width } + inset.left + inset.right,
47+
height: rowHeights.reduce(0) { $0 + $1 } + inset.top + inset.bottom
48+
)
4249
}
4350

4451
// MARK: ListDiffable

Classes/Issues/IssueCommentModelHandling.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ func BodyHeightForComment(
2929
} else if let cache = webviewCache, let viewModel = viewModel as? IssueCommentHtmlModel {
3030
return cache.height(model: viewModel, width: width)
3131
} else if let viewModel = viewModel as? IssueCommentTableModel {
32-
let inset = IssueCommentTableCell.inset
33-
return viewModel.rowHeights.reduce(0) { $0 + $1 } + inset.top + inset.bottom
32+
return viewModel.size.height
3433
} else {
3534
return Styles.Sizes.tableCellHeight
3635
}

0 commit comments

Comments
 (0)