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

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

Issue 2446413002: MD Settings: Ignore whitespace only search queries. (Closed)
Patch Set: Update CL after search URLs landed. 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/test/data/webui/settings/settings_ui_browsertest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/settings/settings_ui/settings_ui.js
diff --git a/chrome/browser/resources/settings/settings_ui/settings_ui.js b/chrome/browser/resources/settings/settings_ui/settings_ui.js
index a3778e74496f8737db93d06a044af5313ab530bf..c7f43de00a76617b7a52b16d7645b66af0afa1e2 100644
--- a/chrome/browser/resources/settings/settings_ui/settings_ui.js
+++ b/chrome/browser/resources/settings/settings_ui/settings_ui.js
@@ -161,7 +161,14 @@ Polymer({
* @private
*/
onSearchChanged_: function(e) {
- var query = e.detail;
+ // Trim leading whitespace only, to prevent searching for empty string. This
+ // still allows the user to search for 'foo bar', while taking a long pause
+ // after typing 'foo '.
+ var query = e.detail.replace(/^\s+/, '');
+ // Prevent duplicate history entries.
+ if (query == this.lastSearchQuery_)
+ return;
+
settings.navigateTo(
settings.Route.BASIC,
query.length > 0 ?
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/settings_ui_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698