Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 1460142 - Use $routeChangeStart for confirm-on-exit
Listen for `$routeChangeStart` instead of `$locationChangeStart` in the
`confirm-on-exit` directive. This prevents us from incorrectly prompting
when the user switches tabs with `persist-tab-state` on.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1460142
  • Loading branch information
spadgett committed Jun 16, 2017
1 parent ed51404 commit 910e642
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions app/scripts/directives/confirmOnExit.js
Expand Up @@ -29,7 +29,11 @@ angular.module("openshiftConsole")
};
$(window).on('beforeunload', confirmBeforeUnload);

var removeLocationChangeListener = $scope.$on('$locationChangeStart', function(event) {
// Use $routeChangeStart instead of $locationChangeStart. Otherwise the
// user is incorrectly prompted when switching tabs with
// `persist-tab-state` on since this changes the URL, but doesn not
// leave the page.
var removeRouteChangeListener = $scope.$on('$routeChangeStart', function(event) {
if (!$scope.dirty) {
return;
}
Expand Down Expand Up @@ -61,8 +65,8 @@ angular.module("openshiftConsole")

$scope.$on('$destroy', function() {
$(window).off('beforeunload', confirmBeforeUnload);
if (removeLocationChangeListener) {
removeLocationChangeListener();
if (removeRouteChangeListener) {
removeRouteChangeListener();
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/scripts/scripts.js
Expand Up @@ -13619,7 +13619,7 @@ return b.message || "You have unsaved changes. Leave this page anyway?";
if (b.dirty) return c();
};
$(window).on("beforeunload", d);
var e = b.$on("$locationChangeStart", function(d) {
var e = b.$on("$routeChangeStart", function(d) {
if (b.dirty) {
var e = new Date().getTime(), f = confirm(c());
if (!f) {
Expand Down

0 comments on commit 910e642

Please sign in to comment.