Skip to content

Commit

Permalink
Invalidate collection view layout on first update
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-magda committed Dec 19, 2023
1 parent dff53c1 commit 4129e3a
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ struct FillBlanksQuizViewWrapper: UIViewRepresentable {
delegate: collectionViewAdapter,
dataSource: collectionViewAdapter
)

// ALTAPPS-1062: Fixes incorrect collection view layout on first update
if context.coordinator.isFirstCollectionViewDataUpdate {
context.coordinator.isFirstCollectionViewDataUpdate = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
uiView.invalidateCollectionViewLayout()
}
}
}

context.coordinator.onInputDidChange = { [weak collectionViewAdapter, weak uiView] inputText, component in
Expand Down Expand Up @@ -76,6 +84,8 @@ extension FillBlanksQuizViewWrapper {
class Coordinator: NSObject, FillBlanksQuizCollectionViewAdapterDelegate {
private(set) var collectionViewAdapter = FillBlanksQuizCollectionViewAdapter()

fileprivate var isFirstCollectionViewDataUpdate = true

var onInputDidChange: ((String, StepQuizFillBlankComponent) -> Void)?

var onDidSelectComponent: ((IndexPath) -> Void)?
Expand Down

0 comments on commit 4129e3a

Please sign in to comment.