diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index f2d7fbcd7b..252bbdfa22 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -82,10 +82,22 @@ define( // Callback for updating the in-scope reference to the object // that is currently navigated-to. function setNavigation(domainObject) { - $scope.navigatedObject = domainObject; - $scope.treeModel.selectedObject = domainObject; - navigationService.setNavigation(domainObject); - updateRoute(domainObject); + if (domainObject === $scope.navigatedObject){ + //do nothing; + return; + } + + if (isDirty() && !confirm(CONFIRM_MSG)) { + navigationService.setNavigation($scope.navigatedObject); + } else { + if ($scope.navigatedObject && $scope.navigatedObject.hasCapability("editor")){ + $scope.navigatedObject.getCapability("editor").cancel(); + } + $scope.navigatedObject = domainObject; + $scope.treeModel.selectedObject = domainObject; + navigationService.setNavigation(domainObject); + updateRoute(domainObject); + } } function setSelectedObject(domainObject) { diff --git a/platform/commonUI/edit/src/capabilities/EditorCapability.js b/platform/commonUI/edit/src/capabilities/EditorCapability.js index 81d3486021..a2938dab3e 100644 --- a/platform/commonUI/edit/src/capabilities/EditorCapability.js +++ b/platform/commonUI/edit/src/capabilities/EditorCapability.js @@ -114,6 +114,7 @@ define( EditorCapability.prototype.cancel = function () { this.editableObject.getCapability("status").set("editing", false); //TODO: Reset the cache as well here. + this.cache.markClean(this.editableObject); return resolvePromise(undefined); };