ionic-framework: [4.0.0-beta.5] Cannot close modal 'overlay does not exist'

After updating to Ionic 4.0.0-beta.5, I get the following error when calling dismiss() on a ModalController when I click on a button:

console.js:35 Error: Uncaught (in promise): overlay does not exist
    at resolvePromise (zone.js:814)
    at resolvePromise (zone.js:771)
    at zone.js:873
    at 

Closing the modal through the backdrop works normally.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 16
  • Comments: 21 (6 by maintainers)

Most upvoted comments

@bleuscyther if we pass 1 as the last argument, it works only for the first dismissing. We can write something like:

this.modalController.dismiss(null, undefined, null);

it would work. But still looks like bug.

@woodstream Indeed, I have found the same in the case of modal overlays.

This works (within the component launched as a modal):

constructor(private ctrl: ModalController) {}

public async close() {
   const modal = await this.ctrl.getTop();
   modal.dismiss();
 }

but this doesn’t:

constructor(private ctrl: ModalController) {}

public close() {
   this.ctrl.dismiss();
 }

whereas the latter used to work in the previous version.

I am now using this method as a workaround.

@abennouna I have read this; this is not the problem. My code used to work in Ionic 4.0.0-beta.4 and is documented here: https://beta.ionicframework.com/docs/api/modal-controller

How do you use it in ts file? I have found the same problem in PopoverController when use ‘this.popoverController.dismiss()’,but use popover which create by PopoverController, popover.dismiss() works well.

I guess it has to do with that: https://github.com/ionic-team/ionic/commit/c1c5102

from the release note (https://github.com/ionic-team/ionic/releases)

Adding an id to the parrams fixes it but the documentation does not mention what these parameters do (data, role, id ), i only know that you can pass data to the parent using data:

  this.modalController.dismiss(null, undefined, 1);

... 'dismiss': (data?: any, role?: string | undefined) => Promise<void>; ...