diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index 180fd8102e..3ec38057fc 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -52,7 +52,11 @@ define( unlisten; unlisten = $scope.$on('$locationChangeSuccess', function () { - $route.current = priorRoute; + // Checks path to make sure /browse/ is at front + // if so, change $route.current + if ($location.path().indexOf("/browse/") === 0) { + $route.current = priorRoute; + } unlisten(); }); // urlService.urlForLocation used to adjust current diff --git a/platform/commonUI/browse/src/BrowseObjectController.js b/platform/commonUI/browse/src/BrowseObjectController.js index c511898871..1826120458 100644 --- a/platform/commonUI/browse/src/BrowseObjectController.js +++ b/platform/commonUI/browse/src/BrowseObjectController.js @@ -54,7 +54,11 @@ define( if (viewKey) { $location.search('view', viewKey); unlisten = $scope.$on('$locationChangeSuccess', function () { - $route.current = priorRoute; + // Checks path to make sure /browse/ is at front + // if so, change $route.current + if ($location.path().indexOf("/browse/") === 0) { + $route.current = priorRoute; + } unlisten(); }); } diff --git a/platform/commonUI/browse/test/BrowseControllerSpec.js b/platform/commonUI/browse/test/BrowseControllerSpec.js index ca9a926f0d..ce9296c239 100644 --- a/platform/commonUI/browse/test/BrowseControllerSpec.js +++ b/platform/commonUI/browse/test/BrowseControllerSpec.js @@ -222,15 +222,20 @@ define( mockNavigationService.addListener.mostRecentCall.args[0]( mockNextObject ); + + // Allows the path index to be checked + // prior to setting $route.current + mockLocation.path.andReturn("/browse/"); + + // Exercise the Angular workaround + mockScope.$on.mostRecentCall.args[1](); + expect(mockUnlisten).toHaveBeenCalled(); + // location.path to be called with the urlService's // urlFor function with the next domainObject and mode expect(mockLocation.path).toHaveBeenCalledWith( mockUrlService.urlForLocation(mockMode, mockNextObject) ); - - // Exercise the Angular workaround - mockScope.$on.mostRecentCall.args[1](); - expect(mockUnlisten).toHaveBeenCalled(); }); }); diff --git a/platform/commonUI/browse/test/BrowseObjectControllerSpec.js b/platform/commonUI/browse/test/BrowseObjectControllerSpec.js index e498c1dc12..9fc7ba3119 100644 --- a/platform/commonUI/browse/test/BrowseObjectControllerSpec.js +++ b/platform/commonUI/browse/test/BrowseObjectControllerSpec.js @@ -68,6 +68,10 @@ define( fireWatch("representation.selected.key", "xyz"); expect(mockLocation.search).toHaveBeenCalledWith('view', "xyz"); + // Allows the path index to be checked + // prior to setting $route.current + mockLocation.path.andReturn("/browse/"); + // Exercise the Angular workaround mockScope.$on.mostRecentCall.args[1](); expect(mockUnlisten).toHaveBeenCalled();