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

[v4.0.0-beta.12] ionViewDidEnter not triggered in modals #15806

Closed
peterpeterparker opened this issue Sep 29, 2018 · 7 comments
Closed

[v4.0.0-beta.12] ionViewDidEnter not triggered in modals #15806

peterpeterparker opened this issue Sep 29, 2018 · 7 comments
Labels

Comments

@peterpeterparker
Copy link
Contributor

Bug Report

Ionic Info

Ionic Angular v4-beta.12

Describe the Bug
Neither ionViewDidEnter nor ionModalDidPresent are triggered modals in v4-beta.12

I created a dummy project to reproduce the issue. Per default the dummy project was created with v4-beta.7 and therefore I was able to also test that effectively these events were still triggered in previous version

Steps to Reproduce

 git clone https://github.com/peterpeterparker/ionic-modal-did-enter
 cd ionic-modal-did-enter
 npm install
 ionic serve
 open the modal

Related Code

https://github.com/peterpeterparker/ionic-modal-did-enter

Expected Behavior
ionViewDidEnter nor ionModalDidPresent should be still triggered in modals too

@ionitron-bot ionitron-bot bot added the triage label Sep 29, 2018
@peterpeterparker peterpeterparker changed the title [v4-beta.12] ionViewDidEnter not triggered in modals [v4.0.0-beta.12] ionViewDidEnter not triggered in modals Sep 29, 2018
@paulstelzer
Copy link
Contributor

All of them is not valid in Ionic 4 as far as I know. You have to use the Angular lifecycle

    ionViewDidEnter() {
        console.log('ionViewDidEnter page');
    }

    ionViewWillEnter() {
        console.log('ionViewWillEnter page');
    }

    ionViewDidLeave() {
        console.log('ionViewDidLeave page');
    }

    ionViewWillLeave() {
        console.log('ionViewWillLeave page');
}

@peterpeterparker
Copy link
Contributor Author

peterpeterparker commented Sep 29, 2018

@paulstelzer only ionViewDidLoad as been replaced with Angular lifecycle. Other events still exists, for reference/example https://github.com/ionic-team/ionic/blob/37c9be7453ceb0e34b28f9c7338c77b90b626d19/core/src/index.ts

In case of the modal, see lifecycle map https://github.com/ionic-team/ionic/blob/c49d896e085278a4ece521a22d983a4fa745adc2/core/src/components/modal/modal.tsx

furthermore, I checked ionViewDidEnter in case of pages, it works fine with v4-beta.12. ionViewDidEnter also worked fine with v4-beta.7 in case of modals, but doesn't work anymore after the upgrade to the last version

@paulstelzer
Copy link
Contributor

I am shocked :D I do not understand why they left the lifecycles in it - ngOnInit etc are already included in Angular, so no need to leave it in

@peterpeterparker
Copy link
Contributor Author

peterpeterparker commented Sep 29, 2018

@paulstelzer I'm really happy they did, easier to migrate and also I think ionViewDidEnter and ionViewWillEnter are really super easy to understand, you know exactly just by the name what they those and what you could do with them

anyhow, maybe I'm totally wrong you know ;) let's see what they say

P.S.: In any case for me no rush anymore, I've already modified my upcoming app in order to not use anymore ionViewDidEnter in case of modal (I still really on it for some pages)

@paulstelzer
Copy link
Contributor

paulstelzer commented Sep 29, 2018

Just use ngOnInit instead of ionViewDidEnter at modals, it's working ;) Upgraded my modals this way, too and componentProps also working in this lifecycle

And yeah, waiting for an answer why they left the lifecycles in it - for me it makes no sense (already hated them in Ionic 3 because it breaks with Angular)

@iharris78
Copy link

I don't think ngOnInit() takes account of the animation of the modal.

I've been trying to hook onto an event that's fired once the modal is presented (ionModalDidPresent), in order to measure some of the elements inside and do a bit of re-sizing - I always get 0 size back when doing this in ngOnInit().

For the time being, I have had to add a setTimeout of 0.5s from ngOnInit() being fired until I do the measuring to allow for the animation delay.

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 7, 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 Nov 7, 2018
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

3 participants