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

Unified Diff: ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.js

Issue 2090513002: MD Search Field: Properly respond to external changes to search value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak test Created 4 years, 6 months 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 | « ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.js
diff --git a/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.js b/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.js
index 1036e4996952dc53524bf62904c73140ab7dd0f4..69f7d8efea827e83b99f64137e49376f762c4da0 100644
--- a/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.js
+++ b/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.js
@@ -26,10 +26,14 @@ Polymer({
type: Boolean,
reflectToAttribute: true
},
+
+ /** @private */
+ hasSearchText_: Boolean,
},
listeners: {
'tap': 'showSearch_',
+ 'searchInput.bind-value-changed': 'onBindValueChanged_',
},
/**
@@ -53,18 +57,21 @@ Polymer({
/** @private */
onInputBlur_: function() {
- if (!this.hasSearchText)
+ if (!this.hasSearchText_)
this.showingSearch = false;
},
/**
- * Expand the search field when a key is pressed with it focused. This ensures
- * it can be used correctly by tab-focusing. 'keypress' is used instead of
- * 'keydown' to avoid expanding on non-text keys (shift, escape, etc).
+ * Update the state of the search field whenever the underlying input value
+ * changes. Unlike onsearch or onkeypress, this is reliably called immediately
+ * after any change, whether the result of user input or JS modification.
* @private
*/
- onSearchTermKeypress_: function() {
- this.showingSearch = true;
+ onBindValueChanged_: function() {
+ var newValue = this.$.searchInput.bindValue;
+ this.hasSearchText_ = newValue != '';
+ if (newValue != '')
+ this.showingSearch = true;
},
/**
« no previous file with comments | « ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698