Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1910)

Unified Diff: chrome/browser/resources/settings/route.js

Issue 2469393004: MD Settings: Preserve search URL param in subpages. (Closed)
Patch Set: Update params. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/settings/settings_menu/settings_menu.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | chrome/browser/resources/settings/settings_menu/settings_menu.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698