Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dismiss mode set to .none always stays on screen #45

Open
elprl opened this issue Aug 2, 2022 · 6 comments
Open

Dismiss mode set to .none always stays on screen #45

elprl opened this issue Aug 2, 2022 · 6 comments

Comments

@elprl
Copy link

elprl commented Aug 2, 2022

$0.dismissal.mode = .none

When setting this mode, the popover will always stick around even when the presenting parent view disappears. Is this as intended?

@aheze
Copy link
Owner

aheze commented Aug 4, 2022

Can't say it's intended, but would it be possible to do present = false inside onDisappear?

@elprl
Copy link
Author

elprl commented Aug 4, 2022

Tried that approach first. Didn't work for me. I'll put together a sample project to demonstrate, just in case it was a result of my complex layouts. I'll close the comment if I can't re-create.

@elprl
Copy link
Author

elprl commented Aug 15, 2022

If you run this code and tap the back button the popover remains on screen. Is this intended? If not, I guess this is a bug.

import SwiftUI
import Popovers

extension String: Identifiable {
    public var id: String {
        return self
    }
}

struct ContentView: View {
    @State var parks: [String] = ["Central", "Greenwich", "Thorpe"]
    
    var body: some View {
        NavigationStack {
            List(parks) { park in
                NavigationLink(park, value: park)
            }
            .navigationDestination(for: String.self) { park in
                ChildView(parkName: park)
            }
        }
    }
}

struct ChildView: View {
    @State var parkName: String
    @State var replyPresent = false

    var body: some View {
        VStack {
            Text(parkName)
            Button {
                self.replyPresent = true
            } label: {
                Text("Show Popover")
            }
        }
        .padding()
        .popover(present: $replyPresent,
                 attributes: {
            $0.dismissal.mode = .none
//            $0.dismissal.mode = .dragUp
//            $0.dismissal.mode = .dragDown
//            $0.dismissal.mode = .tapOutside
        }
        ) {
            Text("My Popover")
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

@massimilianochiodi
Copy link

I have same issue

@aehlke
Copy link
Contributor

aehlke commented Jan 22, 2024

Anyone find a solution?

@aehlke
Copy link
Contributor

aehlke commented Jan 22, 2024

I wonder if this commit in a fork can help resolve this by retaining access to the hosting container: main...chariotsolutions:Popovers:preserve-popover-host#diff-e2a643bfa30cc7d3b75f535698c31a998c099a263a60db12da9ee43c55df1ac6

Could this perhaps be used to force the popover closed inside .onDisappear on the parent view ?

edit: I figured out a solution #93 (comment)

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

No branches or pull requests

4 participants