[Browse] Don't klobber params when preventing default

When browse controller is hijacking a browser navigation event,
it calls preventDefault on the route change.  This has the effect
of preventing all changes in the location (including search changes).

This change checks if other changes were made in the route change and
re-applies them after the navigation has completed.

Fixes a bug where navigating via a link that contained additional
search paramterers would have the effect of navigating but not
keeping the parameters in tact.

Discovered in the course of fixing #1636
This commit is contained in:
Pete Richards 2017-07-04 16:17:33 -07:00
parent 4e7e5bb783
commit 1ae62cde05
2 changed files with 21 additions and 5 deletions

View File

@ -25,8 +25,8 @@
* @namespace platform/commonUI/browse
*/
define(
[],
function () {
['lodash'],
function (_) {
/**
* The BrowseController is used to populate the initial scope in Browse
@ -157,12 +157,28 @@ define(
// (e.g. bookmarks to pages in OpenMCT) and prevent them. Instead,
// navigate to the path ourselves, which results in it being
// properly set.
$scope.$on('$routeChangeStart', function (event, route) {
$scope.$on('$routeChangeStart', function (event, route, oldRoute) {
if (route.$$route === $route.current.$$route) {
if (route.pathParams.ids &&
route.pathParams.ids !== $route.current.pathParams.ids) {
var otherParams = _.omit(route.params, 'ids');
var oldOtherParams = _.omit(oldRoute.params, 'ids');
var deletedParams = _.omit(oldOtherParams, _.keys(otherParams));
event.preventDefault();
navigateToPath(route.pathParams.ids.split('/'));
navigateToPath(route.pathParams.ids.split('/'))
.then(function () {
if (!_.isEqual(otherParams, oldOtherParams)) {
_.forEach(otherParams, function (v, k) {
$location.search(k, v);
});
_.forEach(deletedParams, function (k) {
$location.search(k, null);
});
}
});
} else {
navigateToPath([]);
}

View File

@ -107,7 +107,7 @@ define([
}
this.last = params;
if (params.bounds) {
if (params.clock === 'fixed' && params.bounds) {
if (!this.time.timeSystem() ||
this.time.timeSystem().key !== params.timeSystem) {