Ionic-framework: [DeepLink][Web]Incorrect behavior when use browser's back button

Created on 2 May 2017  路  13Comments  路  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[ ] 1.x
[ ] 2.x
[ x] 3.x

I'm submitting a ... (check one with "x")
[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:
first, at root page "RootPageA" , user navigate to another root page "RootPageB" (using Nav.SetRoot method), then he press browser's back button to go back to the previous root page (RootPageA ). But now, the screen is displayed as it was a pushed page, not a root page (judged by the back button is shown, instead of menu button). Please see this screenshot:
backbug

Expected behavior:
Show menu button.

Most helpful comment

I believe this is fixed with the most recent nav changes. Please let me know if you have issues with ionic-angular 3.5.0 which ships tomorrow.

Thanks,
Dan

All 13 comments

Hello, thanks for using Ionic! Could you post a minimal repo we could use to reproduce this issue?

hi jgw96,
this is my repo, please help me, Thank you very much.

Ps: Please run "npm install" before "ionic serve".
https://drive.google.com/open?id=0Bwrl__NBSvoSdURJRW9heWxzeVE

@danbucholtz
would u please look into this bug?
it's still on the newest release

I investigated the issue and found a workaround. It seems that the segment has the wrong id when using the browser navigation. But i didn't find a way to get the correct one. It's in the _loadViewForSegment helper method where it decides if it should push or pop after the browser url change. Instead of comparing id's i use their names since they seem to be correct.

So instead of:
if (viewController && viewController.id === segment.id) {
i now use:
if (viewController && viewController.name === segment.name) {

I created a fork with the commit which fixes it and it's working for my case, but i'm not sure if this causes any other issues. That's why i won't create a pull request yet.

I believe this is fixed with the most recent nav changes. Please let me know if you have issues with ionic-angular 3.5.0 which ships tomorrow.

Thanks,
Dan

@danbucholtz
OK, I'll check it

I also experienced that my workaround does not work when AOT transpiled. Hope this gets fixed with 3.5.0, so i can delete my fork 馃槃

@danbucholtz Tested with 3.5.0. I can see that the urls now look different. However, the issues persist. For example, using Tabs template, if I go to another tab, push some pages within that tab, click browser's back button, sometimes it jumps back to the previous tab. Other times it pushes the previous tab's root page to the current tab.

This is the result of a quick test. The navigation with browser's back button is still unnatural and buggy.

Also, the ionic team closed several issues as duplicates of this issue. I think although they are all related, each one describes different scenarios. They may be worth to look at or to re-open as this issue is quite complicated. Thanks!

@shawnlan,

The behavior that we currently have is the behavior we want. Perhaps we'll reconsider in the future.

Thanks,
Dan

@danbucholtz Sometimes the recreated page doesn't not get navParams. https://github.com/ionic-team/ionic/issues/11698

I have set rootParams for some tabs. Now each livereload just breaks the page because of this issue.

@shawnlan I am also facing this issue. Have you solved it?

I have this issue and I'm working with "ionic-angular": "3.9.2"

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings