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

Unified Diff: chrome/browser/resources/md_history/history_toolbar.js

Issue 2352293002: MD History: Replace app-route with a custom router (Closed)
Patch Set: Rebase Created 4 years, 3 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
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 488883af151e1edf47f67d7de2b8ce9bbaf0b895..8842be95ef7bd5c11a463be2174ccde058411ef9 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,
},
@@ -74,6 +75,16 @@ Polymer({
},
},
+ /** @return {CrToolbarSearchFieldElement} */
+ get searchField() {
+ return /** @type {CrToolbarElement} */ (this.$['main-toolbar'])
+ .getSearchField();
+ },
+
+ showSearchField: function() {
+ this.searchField.showAndFocus();
+ },
+
/**
* Changes the toolbar background color depending on whether any history items
* are currently selected.
@@ -86,17 +97,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.searchField.getValue() != this.searchTerm) {
+ this.searchField.showAndFocus();
+ this.searchField.setValue(this.searchTerm);
+ }
},
/** @private */
@@ -130,16 +136,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

Powered by Google App Engine
This is Rietveld 408576698