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

Tabs component, ionViewWillEnter is not called on the active Tab, just the page holding the Tabs when doing nav back. #9787

Closed
epetre opened this issue Dec 24, 2016 · 9 comments
Assignees
Labels
ionitron: v3 moves the issue to the ionic-v3 repository

Comments

@epetre
Copy link
Contributor

epetre commented Dec 24, 2016

Ionic version:
[ ] 1.x
[x] 2.x

I'm submitting a ...
[x] bug report
[ ] feature request

Current behavior:
When navigating out of a page with a Tabs component and coming back, the ionViewWillEnter is called on the page holding the tabs component, but not on the active tab.

Expected behavior:
This event should probably be fired on the active tab.

Steps to reproduce:

  1. In a page with tabs, navigate out from the root like this
  2. this.app.getRootNav().push(SomeOtherPage);
  3. Navigate back to return to the tabs page
Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 0.0.48
ios-deploy version: 1.8.6
ios-sim version: 5.0.8
OS: macOS Sierra
Node Version: v4.4.3
Xcode version: Xcode 8.2.1 Build version 8C1002

Sorry about not creating a Plunker, I am really in a rush this month.

Temporary work around
In the parent page that holds the Tabs component:

  isFirstLoad = true;
  ionViewDidEnter(){
    if(!this.isFirstLoad){
      if(this.tabs.getSelected()){
        let t = this.tabs.getSelected();
        let views = t.getViews();
        let v = views[views.length-1].instance;
        if(v.forceWillEnter){
          v.forceWillEnter();
        }
      } 
    } 
    this.isFirstLoad = false;
  }

In the child page (a Tab), I added this:

  forceWillEnter = () => {
    this.ionViewWillEnter();
  }
@jgw96 jgw96 added the v2 label Dec 27, 2016
@vintage
Copy link

vintage commented Mar 4, 2017

I can confirm that it's still an issue in Ionic 2.1.0.

@manucorporat manucorporat self-assigned this Mar 4, 2017
@ippeiukai
Copy link

ippeiukai commented May 16, 2017

I think this is not just the tabs but happening to any nested nav. The ionViewWillEnter is called on the page that is directly under the nav that is going through a transition, but if that page contained a child nav, its active page's ionViewWillEnter does not get called.

@anjildhamala
Copy link

Updating the issue.
version: 3.12.0

I'm navigating from ' TemplatePage' that is in tab navigation to another page using this.navCtrl.parent.parent.push('AddTemplate') and coming back to 'TemplatePage' with the default back button provided by ionic. I have a ionViewWillEnter() function in 'TemplatePage' with a log but that back action doesn't seem to trigger it. Upon changing tabs and coming back, it does fire.

@brunoescalona-zz
Copy link

The same problem here.
ionViewWillEnter() not triggering in the tab page only in the main page containing all the tabs when coming back from another view push from the tab.

@erperejildo
Copy link

is this fixed?

@ygorgasparin
Copy link

I have the same problem here, but I can get a workaround using:

this.appCtrl.getActiveNav().parent.parent

@adamdbradley adamdbradley added the ionitron: v3 moves the issue to the ionic-v3 repository label Nov 1, 2018
@LautaroLorenz
Copy link

LautaroLorenz commented Nov 21, 2018

@Component({
  selector: 'app-my-page',
  templateUrl: './my-page.page.html',
  styleUrls: ['./my-page.page.scss'],
})
export class MyPage {
 ionViewWillEnter() {
    console.log('ionViewWillEnter');
  }
}

to

import { ..., OnDestroy } from '@angular/core';

@Component({
  selector: 'app-my-page',
  templateUrl: './my-page.page.html',
  styleUrls: ['./my-page.page.scss'],
})
export class MyPage implements OnDestroy {
 ionViewWillEnter() {
    console.log('ionViewWillEnter');
  }

  ngOnDestroy(): void {
    console.log('ngOnDestroy');
  }
}

automatically "ionViewWillEnter" starts firing after leave TabsPage and enter on it again
working on Beta ionic 4

@imhoffd imhoffd removed the ionitron: v3 moves the issue to the ionic-v3 repository label Nov 28, 2018
@Ionitron Ionitron added the ionitron: v3 moves the issue to the ionic-v3 repository label Nov 28, 2018
@ionitron-bot
Copy link

ionitron-bot bot commented Nov 28, 2018

This issue has been automatically identified as an Ionic 3 issue. We recently moved Ionic 3 to its own repository. I am moving this issue to the repository for Ionic 3. Please track this issue over there.

If I've made a mistake, and if this issue is still relevant to Ionic 4, please let the Ionic Framework team know!

Thank you for using Ionic!

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 28, 2018

Issue moved to: ionic-team/ionic-v3#159

@ionitron-bot ionitron-bot bot closed this as completed Nov 28, 2018
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ionitron: v3 moves the issue to the ionic-v3 repository
Projects
None yet
Development

No branches or pull requests