Close ion-menu when user click on hardware back button

Hi, I’m new in Ionic and trying to handle the event from hardware backbutton to close my ion-menu when it’s open. But clicking in button navigate to previous page without close it.
What can I do to trigger that event and close ion-menu WITHOUT navigate to previous page?

1 Like

Which Version of the Ionic Framework are you using?

I’m asking because this was implemented in 5.0.2: bug: Hardware Back Button does not close side menu · Issue #20559 · ionic-team/ionic-framework · GitHub

In package-json

@ionic/angular”: “^5.0.0”

I’ll update and check again

Now

@ionic/angular”: “^5.5.4”

No changes for me. Actually I think that issue was made for android not browser. I’m using it on web with capacitor

I’m unsure if this is possible in browser. Does it work for for example Ionic Alerts?

I saw something about HostListener() in Angular docs. I got the event but I still can’t stop the user to go back. Maybe something related to confirm alerts can help.
Like some alerts that appears to user “You will lost the form. Are you sure you want to exit?”
I thinking what they use to do something like that

No. Same problem with Ionic Alerts.
Like I said before, priority problably was solved in native scope (android, ios) not browser