Skip to content

Commit

Permalink
Merge pull request #321 from kyleve/kve/fix-supplementary-reuse-bug
Browse files Browse the repository at this point in the history
Fix supplementary reuse bug by ensuring we track the right view instance in our displayed views cache
  • Loading branch information
kyleve authored Aug 31, 2021
2 parents 600ca93 + b3e27d3 commit 0e55435
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ extension PresentationState
{
var model : Section

var header : HeaderFooterViewStatePair
var footer : HeaderFooterViewStatePair
let header : HeaderFooterViewStatePair
let footer : HeaderFooterViewStatePair

var items : [AnyPresentationItemState]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ final class PresentationState

var refreshControl : RefreshControlState?

var containerHeader : HeaderFooterViewStatePair
var header : HeaderFooterViewStatePair
var footer : HeaderFooterViewStatePair
var overscrollFooter : HeaderFooterViewStatePair
let containerHeader : HeaderFooterViewStatePair
let header : HeaderFooterViewStatePair
let footer : HeaderFooterViewStatePair
let overscrollFooter : HeaderFooterViewStatePair

var sections : [PresentationState.SectionState]

Expand Down
2 changes: 2 additions & 0 deletions ListableUI/Sources/Internal/SupplementaryContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ final class SupplementaryContainerView : UICollectionReusableView
) as! SupplementaryContainerView

view.reuseCache = reuseCache

// TODO: We need to also set this during on-screen updates; I don't think it's updated correctly now.
view.environment = environment

return view
Expand Down
2 changes: 1 addition & 1 deletion ListableUI/Sources/ListView/ListView.Delegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ extension ListView

headerFooter.willDisplay(view: container)

self.displayedSupplementaryItems[ObjectIdentifier(view)] = headerFooter
self.displayedSupplementaryItems[ObjectIdentifier(container)] = headerFooter
}

func collectionView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class SupplementaryContainerViewTests: XCTestCase

// Add a header

view.headerFooter = self.newHeaderFooter()
let header = self.newHeaderFooter()

view.headerFooter = header
view.sizeToFit()

// Make sure the view is set
Expand Down

0 comments on commit 0e55435

Please sign in to comment.