Modal not closing with back button in browser

When you’re using the app in a browser, the back button on the phone navigates you to a previous page completely ignoring the currently opened modals.

I currently use a hack to check if modal is open in beforeRouteLeave and then close it.

Is there any “proper” way to handle this?

This is a limitation in web browsers. Capacitor/Cordova exposes additional information which is why it works when running your app there. See: Hardware Back Button for Capacitor & Cordova on Android Devices

Any other suggestions on tackling this?

beforeRouteLeave thingy worked fine until I had two nested modals… A filters modal and a category picker modal inside it. The back button closes both of them.

I’d recommend avoiding nesting modals as it can result in a confusing user experience. If you can limit it to one open modal at a time that should let you workaround this browser limitation.