Chromium Code Reviews| Index: chrome/browser/resources/md_history/history_toolbar.js |
| diff --git a/chrome/browser/resources/md_history/history_toolbar.js b/chrome/browser/resources/md_history/history_toolbar.js |
| index 23c71de7a3bb669a2ba80286ca119425d7803e99..fb49ee8bda6f76ae56c0d2c4e0bc481df59fd685 100644 |
| --- a/chrome/browser/resources/md_history/history_toolbar.js |
| +++ b/chrome/browser/resources/md_history/history_toolbar.js |
| @@ -26,6 +26,7 @@ Polymer({ |
| // as the user types. |
| searchTerm: { |
| type: String, |
| + observer: 'searchTermChanged_', |
| notify: true, |
| }, |
| @@ -65,6 +66,16 @@ Polymer({ |
| queryEndTime: String, |
| }, |
| + /** @return {CrToolbarSearchFieldElement} */ |
| + get searchBar() { |
|
calamity
2016/09/22 05:12:26
Might be a good time to rename this 'searchField'.
tsergeant
2016/09/23 00:37:44
Done.
|
| + return /** @type {CrToolbarElement} */ (this.$['main-toolbar']) |
| + .getSearchField(); |
| + }, |
| + |
| + showSearchField: function() { |
| + this.searchBar.showAndFocus(); |
| + }, |
| + |
| /** |
| * Changes the toolbar background color depending on whether any history items |
| * are currently selected. |
| @@ -77,17 +88,12 @@ Polymer({ |
| /** |
| * When changing the search term externally, update the search field to |
| * reflect the new search term. |
| - * @param {string} search |
| */ |
| - setSearchTerm: function(search) { |
| - if (this.searchTerm == search) |
| - return; |
| - |
| - this.searchTerm = search; |
| - var searchField = /** @type {!CrToolbarElement} */(this.$['main-toolbar']) |
| - .getSearchField(); |
| - searchField.showAndFocus(); |
| - searchField.setValue(search); |
| + searchTermChanged_: function() { |
| + if (this.searchBar.getValue() != this.searchTerm) { |
| + this.searchBar.showAndFocus(); |
| + this.searchBar.setValue(this.searchTerm); |
| + } |
| }, |
| /** |
| @@ -116,16 +122,6 @@ Polymer({ |
| this.fire('delete-selected'); |
| }, |
| - get searchBar() { |
| - return this.$['main-toolbar'].getSearchField(); |
| - }, |
| - |
| - showSearchField: function() { |
| - /** @type {!CrToolbarElement} */(this.$['main-toolbar']) |
| - .getSearchField() |
| - .showAndFocus(); |
| - }, |
| - |
| /** |
| * If the user is a supervised user the delete button is not shown. |
| * @private |