ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

NavController.remove() doesnt work as expected.

Open NoNameProvided opened this issue 10 years ago • 16 comments

Short description of the problem:

The NavController.remove function doesnt work as docs states. It cant remove pages in some cases when it should be able to.

What behavior are you expecting?

NavController.remove works as docs states and remove pages from the stack the correct way.

Steps to reproduce:

For testing you will have to expose the NavController in the last page with console.log. (In the constructor add console.log(this.nav));

We will use this code snippet to list the stack, because no built in options exist for it now at the moment.

[
(temp1.getByIndex(0))?temp1.getByIndex(0).instance:null,
(temp1.getByIndex(1))?temp1.getByIndex(1).instance:null,
(temp1.getByIndex(2))?temp1.getByIndex(2).instance:null,
(temp1.getByIndex(3))?temp1.getByIndex(3).instance:null,
(temp1.getByIndex(4))?temp1.getByIndex(4).instance:null,
(temp1.getByIndex(5))?temp1.getByIndex(5).instance:null,
]
  1. Push 5 pages to the stack. (The fifth element in the above snipets, confirms our stack is 5 element long.)
  2. In the last page run the code snippet above to check the stack
  3. Run the following code in the console: temp1.remove(temp1.length() - 2, 2)
  4. Check the stack with the snippet above, and notice that only the last element was removed from the stack not the last 2.

Note: This seems not to work only if I try to remove the last 2 page. With the last 1 or 3 it works well. So temp1.remove(temp1.length() - 1, 1) and temp1.remove(temp1.length() - 2, 2) produces the same result.

Which Ionic Version? 2.x

Run ionic info from terminal/cmd prompt: (paste output below)

Cordova CLI: 6.3.1
Gulp version:  CLI version 1.2.2
Gulp local:   Local version 3.9.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
ios-deploy version: 1.9.0 
ios-sim version: 5.0.8 
OS: Mac OS X El Capitan
Node Version: v6.3.1
Xcode version: Xcode 8.0 Build version 8A218a 

NoNameProvided avatar Oct 03 '16 15:10 NoNameProvided

same problem for me here. I have this code that worked on Beta11 but in RC0 it's not working anymore.

this.nav.push(MyNextPage, params).then(() => { this.nav.remove(this.nav.getActive().index - 1, 1); });

I tried to remove the nav.remove from inside the promise but it didn't work either

rodriguesgm avatar Oct 07 '16 01:10 rodriguesgm

Do we have any official hint how to handle this in the meantime?

Our navigation is heavily based on this function. We have pretty hard time figuring out how to solve this efficiently without making big modifications to our current navigation.

NoNameProvided avatar Oct 07 '16 15:10 NoNameProvided

@rodriguesgm can you explain the effect you are going for there? You want to push a new page and then once that's pushed, remove the page you just came from?

I just tested this and the case of removing 1 works for me, digging deeper.

mlynch avatar Oct 09 '16 00:10 mlynch

Weird, this does appear to only break for me once the stack is >= 5. Anyone have a test project to share? I'm not seeing any issues when stack < 5.

mlynch avatar Oct 09 '16 00:10 mlynch

I found the issue, fixing

mlynch avatar Oct 09 '16 00:10 mlynch

Thanks for the info everyone, this is fixed and will be in the next release.

mlynch avatar Oct 09 '16 01:10 mlynch

Hi @mlynch, thanks for the fix! Been trying to debug this for a couple hours, glad to see this issue has been resolved.

Would love for it to be released very soon however :) :) :)

jourdan-jobox avatar Oct 14 '16 00:10 jourdan-jobox

There's a regression on this ?

I have still this issue

numerized avatar Jun 15 '17 11:06 numerized

There's a regression on this ?

I have still this issue

this.navCtrl.remove not work

ThalesMatoso avatar Jul 05 '17 21:07 ThalesMatoso

There's a regression on this ?

I have still this issue

this.navCtrl.remove not work

renanmoraes avatar Jul 06 '17 12:07 renanmoraes

I have the same problem.

this.navCtrl.remove not work

manuvalentim avatar Jul 06 '17 12:07 manuvalentim

If you provide some step you did to debug the problem, and cc a team member, maybe it will be checked sooner. At least test in which version of ionic the regression happened.

(We dont need this right now, so I have no time to check this now.)

NoNameProvided avatar Jul 06 '17 12:07 NoNameProvided

Problem solved #12238

renanmoraes avatar Jul 06 '17 13:07 renanmoraes

I am still facing this issue. Ionic-angular 3.5.3. isTransitioning is still true after remove

supryin avatar Aug 06 '17 16:08 supryin

me too.

numerized avatar Aug 07 '17 13:08 numerized

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[bot] avatar Sep 01 '18 04:09 ionitron-bot[bot]