Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Weird exiting Navigation link when opening a sheet #2

Open
Universumgames opened this issue Aug 1, 2022 · 2 comments
Open

Weird exiting Navigation link when opening a sheet #2

Universumgames opened this issue Aug 1, 2022 · 2 comments

Comments

@Universumgames
Copy link

So basically, what I've done is the following:

NavigationView{
    RefreshableScrollView{
...
        NavigationLink{
            ComponentX.sheet{ComponentB}
        }
    }
}

Now when the sheet is opened, weirdly the navigation link is close, so I jump back to the main page, the Scroll view, the sheet is still opened, but the dismiss() function is not working, so exiting the sheet is only possible via "sliding down". When using the exact same setup with a normal ScrollView instead of the RefreshableScrollView everything works perfectly as it should...
Sadly i don't know how to work around this issue and fix it myself...

@mariogs-dev
Copy link

I have the same behavior but when opening an alert

@mbernson
Copy link
Member

I cannot reproduce the issues you're mentioning. I created this sample which works for me.
Note that when you present the RefreshableScrollView in a sheet, you can't pull it down to dismiss it. It will refresh instead.

The SwiftUI environment works through the UIViewController that RefreshableScrollView uses under the hood. So the dismiss call from SwiftUI works as you would expect.

struct ContentView: View {
    @State var isPresentingSheet = false
    @State var isPresentingAlert = false

    var body: some View {
        RefreshableScrollView {
            Button("Present sheet") {
                isPresentingSheet = true
            }
            .sheet(isPresented: $isPresentingSheet) {
                SheetView()
            }

            Button("Present alert") {
                isPresentingAlert = true
            }
            .alert("Alert", isPresented: $isPresentingAlert, actions: {
                Button("Ok") {}
            })
        }
    }
}

struct SheetView: View {
    @Environment(\.dismiss) var dismiss
    var body: some View {
        RefreshableScrollView {
            Button("Dismiss") {
                dismiss()
            }
        }
    }
}

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

No branches or pull requests

3 participants