Popovers
Popovers copied to clipboard
how to dismiss popover when parent view will disappear
I am using popover in swiftUI project. When I pop the paged attached popover, showed popover doesn't disappear.
How can I dismiss showed popover?
I have same issue
Ever find a solution to this?
I wonder if this commit in a fork can help resolve this by retaining access to the hosting container: https://github.com/aheze/Popovers/compare/main...chariotsolutions:Popovers:preserve-popover-host#diff-e2a643bfa30cc7d3b75f535698c31a998c099a263a60db12da9ee43c55df1ac6 cc @aheze
Could this perhaps be used to force the popover closed inside .onDisappear on the parent view ?
edit: I now see that this change is included in this PR: https://github.com/aheze/Popovers/pull/73
edit: Success! I used that PR plus some other changes to make properties public to retain presentedPopoverContainer in my SwiftUI view that uses popover, then I can dismiss it in onDisappear. Yay. Messy code but maybe there's a way to resolve this within the library itself.
edit: The #73 PR is likely irrelevant to my fix, which just requires exposing presentedPopoverContainer as public and capturing it in a PopoverReader. A better solution would be to solve this inside Popovers itself.