| 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;
|
| },
|
|
|
| /**
|
|
|