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

Ionic 2 Beta 11: loading.dismiss() does not work with other overlays

Open tyftler opened this issue 10 years ago • 7 comments

Since Beta 11 I have this issue:

    let loading = this.loadingCtrl.create({content: 'Loading...'});
    loading.present();

    this.geolocationService.geolocate().subscribe(
      (data) => {
        loading.dismiss();

        let alert = this.alertCtrl.create({
          title: 'Title',
          subTitle: 'Text',
          buttons: ['OK']
        });
        alert.present();
      },
      ...
    );

loading.dismiss() does not have any effect, the loading overlay stays open. loading.destroy() removes it but I guess that is not the way to go.

tyftler avatar Sep 01 '16 10:09 tyftler

I'm also using ionic 2 beta 11 , loading.dismiss() works fine..

Barathwaja avatar Sep 01 '16 13:09 Barathwaja

Hello, thanks for opening am issue with us! Would you mind posting a repo I can use to reproduce this issue? Thanks for using Ionic!

jgw96 avatar Sep 01 '16 13:09 jgw96

Hmm.... some time ago I've have similar issue - not sure if it is Your problem. loading.dismiss() returns promise - try do something like:

loading.dismiss().then(() => {
   ... (place here code you do after dismiss) 
});

especially when You want to open modal - it may causes some kind of lock f.e.:

WRONG

loading.dismiss();
modal.present(); // Loading is not fully closed!! may cause lock!!!

Works

loading.dismiss().then(()=>
    modal.present();
)

For me, loading component works really unstable, it cause locks (f.e. #7948), so I've resigned to use it. I hope it helps...

borys avatar Sep 04 '16 21:09 borys

I agree - this seems to be working fine for me now. But I have a problem with <ion-select>s when using a modal as described here: https://github.com/driftyco/ionic/issues/7839.

kelvindart avatar Sep 05 '16 12:09 kelvindart

Thank you @borys, I forgot to mention the alert I opened after the loading.dismiss() (edited). Your solution fixed it for me. I would consider it being a bug still.

tyftler avatar Sep 05 '16 13:09 tyftler

Hello @tbmk I'm glad @borys was able to help you with your issue! So, this is not actually a bug but simply how our asynchronous navigation works in Ionic 2. You cannot have two transitions going on at the same time, which is why our nav methods return promises to let you know when a transition is done. Thanks for using Ionic!

jgw96 avatar Sep 06 '16 12:09 jgw96

Hmm @jgw96

Barathwaja avatar Oct 26 '16 05:10 Barathwaja