ActionSheet back button on Android browser


#1

We use Ionic to develop both our apps and our mobile website (same code). We are using $ionicActionSheet, and run into problem with the back button in the browser on Android (app works fine). Clicking the back button when the action sheet is open will navigate to the back view as well as close it (due to default cancelOnStateChange). I’ve tried to prevent this by adding this code:

$provide.decorator("$ionicActionSheet", ["$delegate", "$injector", function ($delegate, $injector) {
  // And some stuff...
  $injector.get("$rootScope").$on("$stateChangeStart", function (e) {
    if (openActionSheet) {
      openActionSheet();
      e.preventDefault();
    }
  });
}]);

This works fine, the action sheet is closed and no navigation happens. The problem is that the browser history is still taking one step back, so next time I click the back button it navigates two step back. Here’s an example (remember to run this on an Android phone in the browser, not app): http://codepen.io/bodinaren/embed/mJmpYr

Is there a way to stop the browser history from getting updated in the browser? Or is there a better approach to solve this problem?

Thanks