Ionic 4 - PWA Back Button not closing Modal


#1

Any idea how to fix the back button, both the browser and the android physical button.
In v4 beta.16 when running as normal web page or PWA and a modal is opened then the back button does not close the modal but change the page in background! When you close the modal then you happen to be on a different page :frowning:


#2

You could subscribe to the back event and close the modal aka override de default behavior

To do so you have two options:

  1. In the Platform there is a subscribeWithPriority (https://github.com/ionic-team/ionic/blob/ce1fcea68c7d5e0249c6c1c1fc612a86b2866243/angular/src/providers/platform.ts)

  2. You could use the following decorator to catch the event @HostListener('document:ionBackButton', ['$event'])


Override default back button behaviour
#3

I actually cant get any of these to do something working with beta.17. Am i right at assuming this would handle the in the header as well as the android hardware back button ?


#4

I think there might be still some glitch, depends of your use case. There is a try to have one single issue to consolidate everything which has to do with back button -> https://github.com/ionic-team/ionic/issues/16611


#5

That ticket is related to the android back button. i want to overrride and prevent the default behaviour of the ion-back-button in the ion-toolbar. Is there a way to do that ?