AndreaMiotto / PartialSheet

A SwiftUI Partial Sheet fully customizable with dynamic height

Home Page:https://github.com/AndreaMiotto/PartialSheet/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Binding for presenting partialSheet is not updated correctly when tapping fast to dismiss the sheet.

adiki opened this issue · comments

Steps to reproduce:

  1. Go to PSButton and replace isPresenting.toggle() with isPresenting = true
  2. Open Basic Example
  3. Tap Display button very fast to present and dismiss the sheet
  • Actual behaviour: After a few taps you can't no longer open partial sheet
  • Expected behaviour: You can present and dismiss partial sheet even when tapping very fast on the button and not rely on self recovering mechanism with .toggle() as the binding is not updated correctly.

Confirming this issue! @adiki did you ever find a workaround?

I figured out the reason is:

@Published var isPresented: Bool = false {
        didSet {
            if !isPresented {
                DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) { [weak self] in
                    self?.content = EmptyView().eraseToAnyView()
                    self?.onDismiss = nil
                }
            }
        }
    }

Any fix for this issue?