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

iOS 15, ASCollectionView causes .sheet() to pop unexpectedly #223

Open
andrei115 opened this issue Oct 1, 2021 · 3 comments
Open

iOS 15, ASCollectionView causes .sheet() to pop unexpectedly #223

andrei115 opened this issue Oct 1, 2021 · 3 comments

Comments

@andrei115
Copy link

in ios 15, NavigationLinks inside ASCollectionView are popped when a modal is displayed from the destination view.

struct Test: View {
    var body: some View {
        NavigationView {
            ASCollectionView {
                NavigationLink("navigation link") {
                    TestDestination()
                }
            }
        }
    }
}

struct TestDestination: View {
    @State private var showModal = false
    
    var body: some View {
        VStack {
            Text("destination view")
            Button("click for modal", action: { showModal = true })
                .sheet(isPresented: $showModal, content: { Text("Modal view") })
        }
    }
}
@seboslaw
Copy link

@andrei115 have you found a solution to this problem? A temp solution for me has been to use the tag/selection version of NavigationLink and use a ZStack. But implementing this throughout the app is super cumbersome.

@andrei115
Copy link
Author

@seboslaw I'm not familiar with the tag/selection version of the NavigationLink. The solution for me was to conditionally use LazyGrid for ios14/15 and fallback to ASCollectionView for ios 13. We eventually plan on dropping support for ios 13 as it's really buggy and it does not work well with other libraries(like for example KingFisher for image caching, if you've used)

@seboslaw
Copy link

@andrei115 that sounds like the right decision. The tag/selection version is basically described here: https://stackoverflow.com/a/57837007
You create the NavigationLinks with EmptyViews and set a tag to each. You then assign a State var to capture the selection. And lastly you you a button in your view to set this State var to the tag value you want to navigate to.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants