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

Views stack up and doesn't pop when user leaves view #57

Open
GioPalusa opened this issue Nov 7, 2024 · 3 comments
Open

Views stack up and doesn't pop when user leaves view #57

GioPalusa opened this issue Nov 7, 2024 · 3 comments

Comments

@GioPalusa
Copy link

Something has happened quite recently, when I updated the package our app started behaving weirdly.

When I append a view to a path it navigates there, and I can go back correctly to the view that I was adding. BUT the next time I append a view to the stack, the stack hasn't been popped and I now get first the view I'm currently at, and then also the view that I previously dismissed.

I tried setting a fixed package version to 0.9.3 and then the problem disappeared. So something has happened after that release.

pop-behavior

The setup we have is that each tab gets their own @State private var pathName: NBNavigationPath = .init() on the main view of the app, that handles each tabs stacks, so the app only has three NBNavigationPath in the app, but multiple views append to them via an environment key

import SwiftUI
import NavigationBackport

struct NBNavigationEnvironmentKey: EnvironmentKey {
    static var defaultValue: Binding<NBNavigationPath> = .constant(.init())
}

extension EnvironmentValues {
    var navigationPath: Binding<NBNavigationPath> {
        get { self[NBNavigationEnvironmentKey.self] }
        set { self[NBNavigationEnvironmentKey.self] = newValue }
    }
}
@zjinhu
Copy link

zjinhu commented Nov 8, 2024

I've noticed the same issue

@johnpatrickmorgan
Copy link
Owner

Thanks for raising this @GioPalusa. There's some additional info that might help to pin down the issue, if you're able to provide it please:

  • I'd be a bit wary of passing the path via the environment in that way, as I think it can sometimes cause any screen in the stack to be recomputed when the stack is changed. I'm curious if you still see the same issue if you switch to using the @EnvironmentObject var navigator: PathNavigator environment object provided by this library?
  • Were you able to isolate the issue to a single version change, e.g. 0.9.3 to 0.9.4?
  • Are you able to provide a minimal reproduction that shows the issue?

If you're able to help with any of those, it would be really useful. Thanks!

@theedov
Copy link

theedov commented Nov 25, 2024

@johnpatrickmorgan v0.8.0 was the last version that didn't have this issue.

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