Chromium Code Reviews| Index: chrome/browser/resources/settings/route.js |
| diff --git a/chrome/browser/resources/settings/route.js b/chrome/browser/resources/settings/route.js |
| index d90cbfa73d0ce6e46f40839ac27f1b11fcea9df4..8e57c76b9c91fba9365b11342aebdd75df2d6851 100644 |
| --- a/chrome/browser/resources/settings/route.js |
| +++ b/chrome/browser/resources/settings/route.js |
| @@ -320,8 +320,12 @@ cr.define('settings', function() { |
| * @param {URLSearchParams=} opt_dynamicParameters Navigations to the same |
| * search parameters in a different order will still push to history. |
| */ |
| - var navigateTo = function(route, opt_dynamicParameters) { |
| + var navigateTo = function(route, opt_dynamicParameters, opt_preserveSearch) { |
| + var currentParams = getQueryParameters(); |
| + var oldSearchParam = currentParams.get('search') || ''; |
| + |
| var params = opt_dynamicParameters || new URLSearchParams(); |
| + var newSearchParam = params.get('search') || ''; |
| var url = route.path; |
| if (opt_dynamicParameters) { |
| @@ -330,6 +334,14 @@ cr.define('settings', function() { |
| url += '?' + queryString; |
| } |
| + var preserveSearch = opt_preserveSearch == undefined ? |
| + true : !!opt_preserveSearch; |
| + if (preserveSearch && oldSearchParam.length > 0 && |
| + newSearchParam.length == 0) { |
| + url += '?' + `search=${oldSearchParam}`; |
| + params.append('search', oldSearchParam); |
| + } |
| + |
|
tommycli
2016/11/03 23:31:33
I would recommend doing something like this on lin
dpapad
2016/11/04 02:00:33
Done. I also removed the "if (opt_dynamicParameter
|
| // History serializes the state, so we don't push the actual route object. |
| window.history.pushState(currentRoute_.path, '', url); |
| setCurrentRoute(route, params, false); |