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

Unified Diff: ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js

Issue 2075453002: WebUI cr-search-field: Trigger event after programmatically clearing query. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add 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 | « chrome/test/data/webui/cr_elements/cr_toolbar_search_field_tests.js ('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_search_field/cr_search_field_behavior.js
diff --git a/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js b/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js
index 54374f59b77513455d182eed18fa3cde873b13a5..d61cd6505b077a096159134fedef33a5c0c58b23 100644
--- a/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js
+++ b/ui/webui/resources/cr_elements/cr_search_field/cr_search_field_behavior.js
@@ -44,14 +44,14 @@ var CrSearchFieldBehavior = {
},
/**
- * Sets the value of the search field, if it exists.
+ * Sets the value of the search field.
* @param {string} value
*/
setValue: function(value) {
// Use bindValue when setting the input value so that changes propagate
// correctly.
this.$.searchInput.bindValue = value;
- this.hasSearchText = value != '';
+ this.onValueChanged_(value);
},
showAndFocus: function() {
@@ -65,7 +65,16 @@ var CrSearchFieldBehavior = {
},
onSearchTermSearch: function() {
- var newValue = this.getValue();
+ this.onValueChanged_(this.getValue());
+ },
+
+ /**
+ * Updates the internal state of the search field based on a change that has
+ * already happened.
+ * @param {string} newValue
+ * @private
+ */
+ onValueChanged_: function(newValue) {
if (newValue == this.lastValue_)
return;
@@ -88,7 +97,6 @@ var CrSearchFieldBehavior = {
this.setValue('');
this.$.searchInput.blur();
- this.onSearchTermSearch();
},
/** @private */
« no previous file with comments | « chrome/test/data/webui/cr_elements/cr_toolbar_search_field_tests.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698