Back button doesn't close modal

I need to open modals programmatically (no route change) for some of my views, since I don’t want them to appear on reload. My problem is that the modal doesn’t close when user presses history back button.

I’ve done my googling but can’t find a way to fix this. Had anybody had the same problem?

Thanks in advance/T

Can you provide your example code?

    const open_modal = async () => {
      const modal = await modalController.create({
        // component: ,

      const response = await modal.onWillDismiss();

Your not handling how to close the modal. The docs show an example on how to do that. ion-modal: Ionic Mobile App Custom Modal API Component

I can’t find any reference how to handle closing of the modal with the history back button.

I know how to close the modal with a function, as mentioned in the documentation.

Note sure what you’re referring to. Please elaborate.

Thank you

Yeah, I’ve seen that – thank you for googling for me. So I guess using modal navigation isn’t something they recommend if you want to retain expected native behaviour then.

1 Like