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

Ionic2 RC.0 - Tab page leave lifecycle events do not fire #8547

Closed
zakton5 opened this issue Oct 6, 2016 · 8 comments
Closed

Ionic2 RC.0 - Tab page leave lifecycle events do not fire #8547

zakton5 opened this issue Oct 6, 2016 · 8 comments
Assignees

Comments

@zakton5
Copy link
Contributor

zakton5 commented Oct 6, 2016

Short description of the problem:

I already know this will probably get dismissed, just like #8233, #5351, and so on. But I'm pretty sure this problem arises from having a Tabs page at a place other than the root of the application.

These lifecycle events such ionViewWillLeave only fire when clicking on another tab. But if navigating away with a Menu or a Custom Back Button (with this.nav.parent.parent.pop()), the events do not fire. I mean, the fact that I even have a custom back button is solely because Tabs is only allowed at the root. So I am once again requesting that Tabs be allowed to exist anywhere on the stack...But at the very least I'm hoping this issue will be fixed.

Let me know if you want a plunker.

What behavior are you expecting?

I expect all lifecycle events to fire properly no matter where I am in the stack.

@manucorporat manucorporat self-assigned this Oct 6, 2016
@mlynch
Copy link
Contributor

mlynch commented Oct 7, 2016

I just tested this and ionViewWillLeave on a tabs page after popping works for me. I'm using tabs not a the root of the app.

Can you share some code? Or, try master as I just pushed a fix that maybe is related (tested w and w/o the fix though)

@zakton5
Copy link
Contributor Author

zakton5 commented Oct 7, 2016

hm yeah ill try that out with master and see it works. Could you direct me to the commit that may have fixed it? Is there a plunker template anywhere for rc.0?

@zakton5
Copy link
Contributor Author

zakton5 commented Oct 7, 2016

@mlynch In what way are you popping from the tabs page. Is it like what I did? this.nav.parent.parent.pop()

@zakton5
Copy link
Contributor Author

zakton5 commented Oct 7, 2016

After a bit more testing, I have found the following behavior in the rc.0 code.

  1. ionViewCanLeave only fires on a tab page when pushing a page onto that Tabs navstack.
  2. ionViewWillLeave on tab pages only fire when navigating between other tab pages, and pushing onto that Tab's navstack.
  3. ionViewCanEnter only fires the first time a tab page is entered (this may be working as intended, but I don't know because there is no documentation)

@jgw96 jgw96 added the v2 label Oct 7, 2016
@peterpeterparker
Copy link
Contributor

peterpeterparker commented Oct 17, 2016

Same here, I was excepting that ionViewWillLeave or ionViewDidLeave would have been triggered on the main TabsPage when another pages would have been set as new root, but it isn't the case.

Or maybe it's just a misunderstanding of my side of the lifecycle events. In such case, is there any documentation about the lifecycle events, specially when using tabs and what happens (aka what is triggered) when something is pushed or set as new root?

@manucorporat
Copy link
Contributor

NOTE TO MYSELF:

should be resent the lifecycle events to the active tab when we are leaving the all the tabs (setRoot)?

@badpenguin
Copy link

badpenguin commented Jan 25, 2017

Just found this today with the final. Using setRoot from within a tab does not trigger the WillLeave,Leave and Unload events for the tab.

However ngOnDestroy() for the tab is being called.

@ionitron-bot
Copy link

Ionitron Bot bot commented Mar 26, 2018

Thanks for the issue! This issue is being closed due to inactivity. 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.

Thank you for using Ionic!

@ionitron-bot Ionitron Bot bot closed this as completed Mar 26, 2018
@ionitron-bot Ionitron Bot bot locked and limited conversation to collaborators Mar 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

6 participants