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

navController.setRoot(Page) does not work inside a popover #8437

Closed
pdrosos opened this issue Oct 3, 2016 · 15 comments
Closed

navController.setRoot(Page) does not work inside a popover #8437

pdrosos opened this issue Oct 3, 2016 · 15 comments
Assignees

Comments

@pdrosos
Copy link

pdrosos commented Oct 3, 2016

Short description of the problem:

When trying to navigate to a new page via an anchor click and call navController.setRoot(Page) inside a popover, the new page is not displayed. If navController.push(Page) is used instead, the page is displayed. Tested with Firefox, Chrome and Android 5.0.

What behavior are you expecting?

I expect the page, set via navController.setRoot inside the popover component to show up.

Steps to reproduce:

  1. Create a new project, based on the tabs template: ionic start ProjectName --v2
  2. Add a button, which opens a popover on the home page's header.
  3. Inside the popover page, add an anchor, which on click must navigate to other page: this.navController.setRoot(Page);
  4. When this anchor is clicked, the new page is not displayed.

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)
A repository, which demonstrates the problem can be found here.

Which Ionic Version? 1.x or 2.x
2.0.0-rc.0, 2.0.0-rc.1

Run ionic info from terminal/cmd prompt: (paste output below)
Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS: Distributor ID: LinuxMint Description: Linux Mint 18 Sarah
Node Version: v6.7.

@jgw96 jgw96 added the v2 label Oct 3, 2016
@pdrosos
Copy link
Author

pdrosos commented Oct 4, 2016

@jgw96 @danbucholtz is there a chance this one to be fixed in the next RC release? It used to work in beta11 and after the update to rc0 it's no longer working. I need it in my app, because I have a logout button inside a popover, which must take user to login page via navController.setRoot(LoginPage); and now the LoginPage is not displayed anymore.

Thanks!

@pufanalexandru
Copy link

I have the same problem, any news about this?

@daveshirman
Copy link

Same problem within a modal window too.

@Geoffrey-D
Copy link

Geoffrey-D commented Oct 8, 2016

same problem with a popover. The new page is loaded (when I check the DOM I can see it) but the 'old' page is still displayed. It seems that the page from which the popover has been invoked is not destroyed, as you can see here :

image

The "app-root" is the old page (that was hosting the popover and that should not been displayed anymore) and the "ion-page" is the page that should be displayed.

It worked on beta-11 but not on RC-0

@pdrosos
Copy link
Author

pdrosos commented Oct 10, 2016

@danbucholtz @brandyscarney could you please let us know if this could be fixed, or we need to change the UI of our apps? It's important to know if I must move the button, which opens a new page via setRoot outside the popover.

@devarg
Copy link

devarg commented Nov 13, 2016

@pdrosos You may workaround it with events api. Make your app-component subscribe to a event you may call "app:logout" and set the root page to the login from there. Inject Event from constructor so you can publish the "app:logout" event from your popover.

@jgw96
Copy link
Contributor

jgw96 commented Nov 14, 2016

Hello @pdrosos and @devarg, sorry for the delay on this! So the correct method to use to setRoot on the "base" page from a popover is this this.app.getRootNav().setRoot(SupportPage);. This will get the NavController of the base page (not the popover) and run a setRoot on that NavController.

@jgw96 jgw96 closed this as completed Nov 14, 2016
@bgondy
Copy link

bgondy commented Feb 1, 2017

For beginners like me who didn't understand where this.app comes from (in the previous comment), you need to inject App in the popover's constructor (constructor(protected app: App){} and import {App} from "ionic-angular";). Hope it helps!

@daveshirman
Copy link

daveshirman commented Feb 1, 2017

@jgw96 @manucorporat I still get a white screen of death if I try to redirect using setRoot from anywhere other than a root level page.

Bottom line is this issue should not be closed. It is still present. See gif below when redirecting from a 2nd level page in:

My app receives a logout event in the app.component class and does exactly as stated above:

this.app.getRootNav().setRoot(LoginPage)

Yet, as you can see, I get a white screen of death.
When i switch tasks using the system button, the page is rendered again.

e582332 2 a 5 11daveshirman02012017184734

@danielehrhardt
Copy link
Contributor

Same here

@Micheloss
Copy link

Same here, Does someone has any kind of work around?

@rafaret12
Copy link

hello ... I am in urgent need of the version NavController_Release_v6 who could send me doing a favor email: [email protected] since thanks

@iamisti
Copy link

iamisti commented Feb 13, 2018

have the same white dead screen... and what is more irritating is that there is no way of debugging when running natively

@vagnersabadi
Copy link

vagnersabadi commented Aug 27, 2018

One solution I found was to close the popover and then call setRoot
close(){
this.viewCtrl.dismiss();
this.navCtrl.setRoot(IntroPage);
}

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 26, 2018

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests