johnpatrickmorgan / FlowStacks

FlowStacks allows you to hoist SwiftUI navigation and presentation state into a Coordinator
MIT License
783 stars 56 forks source link

Dismiss when nothing is presented remove the root node #50

Closed lionel-alves closed 1 year ago

lionel-alves commented 1 year ago

Hi @johnpatrickmorgan,

Issue: when we call dismiss with only the .root node we get a black screen.

It can be useful to call dismiss to make sure nothing is presented before presenting something, for example for deep-linking from a push notification. The issue is the dismiss function test if the node isPresented if so it removes it, but the .root node uses a .sheet so isPreview is true. Imo dismissing when there is only the root should do nothing. Wdyt?

johnpatrickmorgan commented 1 year ago

Thanks for raising this issue @lionel-alves - you're right, this behaviour is not right.

Rather than allowing dismiss() to be a no-op when there is nothing to dismiss, I've added a utility dismissAll(), which will dismiss all presentation layers, and won't complain if there's nothing to dismiss. This is in keeping with pop() and goBack() which both throw an assertion failure if there is nothing to pop / goBack.

The new API is available in 0.3.0. Hope that helps your use case!