mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 01:42:31 +00:00
[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:
parent
4e7e5bb783
commit
1ae62cde05
@ -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([]);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user