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

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

Issue 2469393004: MD Settings: Preserve search URL param in subpages. (Closed)
Patch Set: Function params nit. 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.html » ('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..4718a1fe8e2faccd95f29d68bf4c17180f415296 100644
--- a/chrome/browser/resources/settings/route.js
+++ b/chrome/browser/resources/settings/route.js
@@ -318,17 +318,24 @@ cr.define('settings', function() {
* Navigates to a canonical route and pushes a new history entry.
* @param {!settings.Route} route
* @param {URLSearchParams=} opt_dynamicParameters Navigations to the same
- * search parameters in a different order will still push to history.
+ * URL parameters in a different order will still push to history.
+ * @param {boolean=} opt_removeSearch Whether to strip the 'search' URL
+ * parameter during navigation. Defaults to false.
*/
- var navigateTo = function(route, opt_dynamicParameters) {
+ var navigateTo = function(route, opt_dynamicParameters, opt_removeSearch) {
var params = opt_dynamicParameters || new URLSearchParams();
+ var removeSearch = !!opt_removeSearch;
+
+ var oldSearchParam = getQueryParameters().get('search') || '';
+ var newSearchParam = params.get('search') || '';
+
+ if (!removeSearch && oldSearchParam && !newSearchParam)
+ params.append('search', oldSearchParam);
var url = route.path;
- if (opt_dynamicParameters) {
- var queryString = opt_dynamicParameters.toString();
- if (queryString)
- url += '?' + queryString;
- }
+ var queryString = params.toString();
+ if (queryString)
+ url += '?' + queryString;
// History serializes the state, so we don't push the actual route object.
window.history.pushState(currentRoute_.path, '', url);
« no previous file with comments | « no previous file | chrome/browser/resources/settings/settings_menu/settings_menu.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698