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

bug: Lifecycle hooks ionViewWillEnter, ionViewDidEnter aren't fired when navigating back to the page #29282

Closed
3 tasks done
gultyayev opened this issue Apr 5, 2024 · 2 comments
Assignees
Labels

Comments

@gultyayev
Copy link

gultyayev commented Apr 5, 2024

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

The ViewWillEnter, ViewDidEnter lifecycle hooks don't fire when I navigate back to the page when popping the stack by pressing the <ion-back-button>

Expected Behavior

According to the documentation those should fire always regardless whether the page was initialized or not.

Steps to Reproduce

  1. Click on "Child page"
  2. Click on the back button in the header
  3. Observe no logs from ViewWillEnter and ViewDidEnter

Code Reproduction URL

https://stackblitz.com/edit/stackblitz-starters-rzsdv4?file=src%2Fmain.ts%3AL72

Ionic Info

Ionic:
Ionic CLI : 7.2.0
Ionic Framework : @ionic/angular 7.7.4
@angular-devkit/build-angular : 17.3.0
@angular-devkit/schematics : 17.3.0
@angular/cli : 17.3.0
@ionic/angular-toolkit : 11.0.1
Capacitor:
Capacitor CLI : 5.7.2
@capacitor/android : 5.7.2
@capacitor/core : 5.7.2
@capacitor/ios : 5.7.2
Utility:
cordova-res : not installed globally
native-run : 2.0.1
System:
NodeJS : v20.11.1 (/Users/shultiaiev/homebrew/Cellar/node@20/20.11.1_1/bin/node)
npm : 10.2.4
OS : macOS Unknown

Additional Information

No response

@thetaPC
Copy link
Contributor

thetaPC commented Apr 9, 2024

Thank you for submitting the issue!

This is working as intended. When you go from a tabs page to a non-tabs page (your child page), the entire tabs context is considered "leaving". However within the tabs context itself, Tab 1 is still active which is why the lifecycles are not firing on Tab 1 when going to a non-tabs page. You can test this by logging something in the ionViewWillEnter hook on the TabsComponent:

class TabsComponent {
  ionViewDidEnter() {
    console.log('view did enter 2');
  }

  ionViewWillEnter() {
    console.log('view will enter3');
  }
}

There's a workaround that might be of interest to you.

@thetaPC thetaPC closed this as not planned Won't fix, can't repro, duplicate, stale Apr 9, 2024
Copy link

ionitron-bot bot commented May 9, 2024

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 May 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants