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

Circular backstack when using navigation menu #64

Open
krestenlaust opened this issue Nov 9, 2023 · 3 comments
Open

Circular backstack when using navigation menu #64

krestenlaust opened this issue Nov 9, 2023 · 3 comments
Labels
a-core Area: core-functionality c-feature Category: feature d-medium Difficulty: medium p-low Priority: low

Comments

@krestenlaust
Copy link
Member

An example in navigation: (1) Main menu -> (2) songbook -> (3) a song -> (4) main menu -> (5) songbook -> (6) main menu.

Now using back navigation, the stack just pops as presented. Instead you expect the stack to not include duplicates, so when step 5 is reached, all views until the identical step 2 should be popped, so the stack looks like (1) main menu -> (2) songbook instead.

That's my understanding anyway, source: https://developer.android.com/guide/navigation/backstack/circular

@jonasKjellerup
Copy link
Collaborator

Honestly I'm not entirely sure that I understand what you are suggesting.

Currently we just use the default browser behavior. But I assume what you are trying to get at is something like a tree structure, where pressing the back button will always go one step up in the tree.

E.g. If we were to somehow navigate to /songbook/songA from /stregsystem the back button will bring us to /songbook and not /stregsystem.

@krestenlaust
Copy link
Member Author

No.. that's not it.

I'm not sure that I am able to explain it better 🤔
I think the idea is just that the same page can't be in the backstack twice, if it already exists, then past entries up until that page should be removed. I haven't implemented it myself, but that's the way I understand it. The link I referred originally has a pretty good demonstration/example of the undesirable situation

@jonasKjellerup jonasKjellerup added c-feature Category: feature d-medium Difficulty: medium a-core Area: core-functionality p-low Priority: low labels Mar 7, 2024
@jonasKjellerup
Copy link
Collaborator

Looking back at the link and your original example, I think I get it now. The main thing that got me confused is that the example you provided marks the (4)->(5) transition as the where the unwinding happens, but it is at the (3)->(4) transition as the main menu is already on the stack.

Basically in pseudo code:

navigateTo(path) {
  if backStack.contains(path) {
    backStack = backStack.takeWhile(x => x != path)
  }
  backStack.push(path)
}

With how simple the page flow is in the app, I don't see any issue with using this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-core Area: core-functionality c-feature Category: feature d-medium Difficulty: medium p-low Priority: low
Projects
None yet
Development

No branches or pull requests

2 participants