Skip to content
This repository was archived by the owner on Nov 4, 2022. It is now read-only.
This repository was archived by the owner on Nov 4, 2022. It is now read-only.

Collection view hidden when embedded in ScrollView #152

@joeycarmello

Description

@joeycarmello

Describe the bug

I'm attempting to use the tags example from the demo in a simple ScrollView. The demo renders successfully without the ScrollView, but renders nothing at all when embedded within a ScrollView. I've tried variations of settings explicit frames on the collection view and items.

To Reproduce

Minimal example preview:

struct TagExample_Previews: PreviewProvider {
    struct DataItem: Identifiable {
        let id = UUID()
        let name: String
    }
    
    static var previews: some View { 
        let data: [DataItem] = [
            .init(name: "one"),
            .init(name: "second"),
            .init(name: "three"),
            .init(name: "four"),
        ]
        
        return Group {
            ScrollView {
                VStack {
                    ASCollectionView(
                        section: ASCollectionViewSection(
                            id: 0,
                            data: data,
                            contentBuilder: { (item, _) in
                                Text(item.name)
                        })
                        .selfSizingConfig { _ in
                            ASSelfSizingConfig(canExceedCollectionWidth: false)
                        }
                    )
                    .layout {
                        let fl = AlignedFlowLayout()
                        fl.estimatedItemSize = UICollectionViewFlowLayout.automaticSize
                        return fl
                    }
                    .shrinkToContentSize(isEnabled: true, dimension: .vertical)
                }
            }
        }
    }
}

Expected behaviour

The collection view should render correctly within a ScrollView using self-sizing items.

Screenshots

Without ScrollView:

Screen Shot 2020-06-03 at 11 36 17 AM

Xcode Version:

  • 11.5

Simulator, Device, Both?

  • Simulator

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions