Chromium Code Reviews| 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_', |
|
dpapad
2016/06/22 18:18:36
I am a bit confused by the fact that this fix seem
tsergeant
2016/06/23 00:02:49
I made the changes here since the problems I'm try
dpapad
2016/06/23 00:44:19
Thanks for the explanation. Given that the canonic
|
| }, |
| /** |
| @@ -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() { |
|
dpapad
2016/06/22 18:18:36
There is already an onValueChanged_() method respo
tsergeant
2016/06/23 00:02:49
I've tried to allude to this in the comment, but w
dpapad
2016/06/23 00:44:19
I understand now, thanks. It was not clear to me i
|
| + var newValue = this.$.searchInput.bindValue; |
| + this.hasSearchText_ = newValue != ''; |
| + if (newValue != '') |
| + this.showingSearch = true; |
| }, |
| /** |