Having two Modals has presented a challenge for me when it comes to closing the first modal after the second one is opened.
I attempted a solution, but it prevented the second Modal from opening altogether.
This code snippet below belongs to the first Modal:
async next(): Promise<void> { // try to open 2nd Modal and after that close the 1st Modal
await this.showSeeAgainModal();
this.cancel();
}
cancel(): void {
this.modalController.dismiss();
}
async showSeeAgainModal(): Promise<void> { // This is the 2nd Modal
const modal: HTMLIonModalElement = await this.modalController.create({
component: SeeAgainPage,
});
modal.onDidDismiss().then(async (res) => {
});
return await modal.present();
}
Update: I experimented with using 2 ModalControllers - one for the parent and one for the child. Unfortunately, this approach did not resolve the issue either.