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

Side by Side Diff: chrome/browser/resources/settings/settings_ui/settings_ui.js

Issue 2446413002: MD Settings: Ignore whitespace only search queries. (Closed)
Patch Set: Add test. 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'settings-ui' implements the UI for the Settings page. 7 * 'settings-ui' implements the UI for the Settings page.
8 * 8 *
9 * Example: 9 * Example:
10 * 10 *
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 var searchField = /** @type {CrToolbarSearchFieldElement} */ ( 124 var searchField = /** @type {CrToolbarSearchFieldElement} */ (
125 toolbar.getSearchField()); 125 toolbar.getSearchField());
126 searchField.setValue(searchQuery); 126 searchField.setValue(searchQuery);
127 }, 127 },
128 128
129 /** 129 /**
130 * @param {!Event} e 130 * @param {!Event} e
131 * @private 131 * @private
132 */ 132 */
133 onSearchChanged_: function(e) { 133 onSearchChanged_: function(e) {
134 var query = e.detail; 134 // Ignore query if it contains whitespace only.
Dan Beam 2016/10/26 20:51:11 i think this entire patch could be - var query =
dpapad 2016/11/03 21:00:11 See latest patch for a very similar approach.
135 // TODO(dpapad): Should this be done by cr_search_field_behavior instead?
dpapad 2016/10/25 23:38:41 MD History would probably benefit by moving this l
Dan Beam 2016/10/26 02:10:03 can we just put the fix in a shared place? downlo
136 if (/^\s+$/.test(e.detail))
dpapad 2016/10/25 23:38:41 FWIW, I looked into Downloads, specifically at [1]
137 return;
Dan Beam 2016/10/26 20:51:11 this code is wrong. consider moving from ' a' to
dpapad 2016/11/03 21:00:11 Addressed in latest patch.
135 138
136 // 'search-changed' event was fired only because the search box's value was 139 var query = e.detail.trim();
137 // updated to reflect the already existing search URL parameter, no need to 140
138 // navigate again.
139 var existingQuery = settings.getQueryParameters().get('search') || ''; 141 var existingQuery = settings.getQueryParameters().get('search') || '';
140 if (query == existingQuery) 142 if (query == existingQuery) {
143 // 'search-changed' event was fired only because the search box's value
144 // was updated to reflect the already existing search URL parameter, no
145 // need to navigate again.
141 return; 146 return;
147 }
142 148
143 settings.navigateTo( 149 settings.navigateTo(
144 settings.Route.BASIC, 150 settings.Route.BASIC,
145 query.length > 0 ? new URLSearchParams(`search=${query}`) : undefined); 151 query.length > 0 ? new URLSearchParams(`search=${query}`) : undefined);
146 }, 152 },
147 153
148 /** 154 /**
149 * @param {Event} event 155 * @param {Event} event
150 * @private 156 * @private
151 */ 157 */
152 onIronActivate_: function(event) { 158 onIronActivate_: function(event) {
153 if (event.detail.item.id != 'advancedPage') 159 if (event.detail.item.id != 'advancedPage')
154 this.$$('app-drawer').close(); 160 this.$$('app-drawer').close();
155 }, 161 },
156 162
157 /** @private */ 163 /** @private */
158 onMenuButtonTap_: function() { 164 onMenuButtonTap_: function() {
159 this.$$('app-drawer').toggle(); 165 this.$$('app-drawer').toggle();
160 }, 166 },
161 167
162 /** @private */ 168 /** @private */
163 directionDelegateChanged_: function() { 169 directionDelegateChanged_: function() {
164 this.$$('app-drawer').align = this.directionDelegate.isRtl() ? 170 this.$$('app-drawer').align = this.directionDelegate.isRtl() ?
165 'right' : 'left'; 171 'right' : 'left';
166 }, 172 },
167 }); 173 });
OLDNEW
« 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