Skip to content

Commit 8b570f3

Browse files
committed
Only update collection view layout when cell config changes so that the images don't jump to the beginning on any image statuses change.
1 parent 4a6a63d commit 8b570f3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

WooCommerce/Classes/ViewRelated/Products/Cells/Product Images/ProductImagesHeaderTableViewCell.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ final class ProductImagesHeaderTableViewCell: UITableViewCell {
2121
///
2222
var onAddImage: (() -> Void)?
2323

24+
/// Keeps track of the cell config to update collection view layout on change.
25+
///
26+
private var config: ProductImagesCellConfig?
27+
2428
override func awakeFromNib() {
2529
super.awakeFromNib()
2630

@@ -120,6 +124,13 @@ private extension ProductImagesHeaderTableViewCell {
120124
collectionView.dataSource = dataSource
121125
collectionView.backgroundColor = .systemColor(.secondarySystemGroupedBackground)
122126
collectionView.showsHorizontalScrollIndicator = false
127+
128+
guard config != self.config else {
129+
return
130+
}
131+
132+
self.config = config
133+
123134
switch config {
124135
case .extendedAddImages:
125136
collectionView.collectionViewLayout = ProductImagesFlowLayout(itemSize: frame.size, config: config)

0 commit comments

Comments
 (0)