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

Browser Back button doesn't work, even in example code #554

Closed
hemanthvings opened this issue Jul 31, 2022 · 1 comment
Closed

Browser Back button doesn't work, even in example code #554

hemanthvings opened this issue Jul 31, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@hemanthvings
Copy link

hemanthvings commented Jul 31, 2022

Describe the bug
Browser Back button doesn't work, haven't tested in mobile
Only url changes page or title won't change

Beamer version: (e.g. v0.14.1, master, ...)
1.5.0

To Reproduce
Steps to reproduce the behavior:
Run the example: bottom_navigation

Expected behavior
url change should change the page also

Screenshots

2022_07_31_212401.mp4
@slovnicki slovnicki added the bug Something isn't working label Aug 16, 2022
@slovnicki
Copy link
Owner

Hey @hemanthvings 👋
Thanks for creating an issue and sorry for a late response.

This is a strange issue that I've been seeing in some old versions too. Interesting fact is that after some more navigation, browser buttons seem to work as expected.

I have now investigated it fully and can provide a detailed explanation of why it happened.
In the MyApp, for the "root screen" we have this configuration

 routes: {
  '*': (context, state, data) => HomeScreen(),
},

Now RoutesLocationBuilder must surround the HomeScreen widget with a BeamPage and provide a key for it. The key to be selected is something like ValueKey(state.routeInformation.location). The important thing to note here is that Navigator will rebuild its pages only if the key has changed between 2 navigation events.

So we start of with that 1 root page in our root Navigator and it initially has the key ValueKey(/books). Then we navigate (but with nested Beamer!) to /articles or /books/2 and see that the nested Beamer properly updates the URL. When we press the browser back button to go back to /books, that event goes to root Beamer (the one with 1 root page with ValueKey(/books)), so it decides not to rebuild itself because this is the same key that the page already has!

The solution is for nested Beamer to properly rebuild when listening to changes on its parent. There was a bug that @MarkRunWu noticed as a related issue and fixed before I managed to take a proper look due to vacation and illness. Thanks again! 💙
So now the 1 root page will still not rebuild (and this is OK), but the nested Beamer that was on /books/2 or /articles will rebuild when its parents notifies it of /books.

I am now going to cherry-pick this into v1.5 branch and publish v1.5.2 on pub dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants