With the latest update to Ionic 5's ModalController, a new feature allows users to swipe down on a modal to close it in addition to using the backdropDismiss parameter. Here is an example of how to enable this functionality:
const modal = await this.modalController.create({
component: ModalPage,
backdropDismiss: true, // <-- enable backdrop dismiss
swipeToClose: true, // <-- enable swipe to close
presentingElement: await this.modalController.getTop()
});
return await modal.present();
When a user triggers the swipeToClose
or backdropDismiss
events, is there a way to pass data back to the onWillDismiss()
or onDidDismiss()
events?
I know about the dismiss()
method which can be used to send data back to the originating component programmatically. However, this method does not address passing data back when the swipeToClose
or backdropDismiss
events occur.
It might not be possible to achieve this directly, and I can think of a workaround if needed. But before doing that, I wanted to ask this question here first.