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

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

Issue 2586803002: MD Settings: Fix label visibility in subpage search fields (Closed)
Patch Set: Rebase Created 3 years, 11 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: 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 68c15d4ff6146d481f0c60d025cb8dfaa58dc179..491bbb53d601264a1059da22c8096280ae59a584 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
@@ -19,6 +19,12 @@ var CrSearchFieldBehavior = {
value: '',
},
+ hasSearchText: {
+ type: Boolean,
+ reflectToAttribute: true,
+ value: false,
+ },
+
/** @private */
lastValue_: {
type: String,
@@ -49,6 +55,8 @@ var CrSearchFieldBehavior = {
setValue: function(value, opt_noEvent) {
var searchInput = this.getSearchInput();
searchInput.value = value;
+
+ this.onSearchTermInput();
this.onValueChanged_(value, !!opt_noEvent);
},
@@ -57,6 +65,15 @@ var CrSearchFieldBehavior = {
},
/**
+ * 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.
+ */
+ onSearchTermInput: function() {
+ this.hasSearchText = this.$.searchInput.value != '';
+ },
+
+ /**
* Updates the internal state of the search field based on a change that has
* already happened.
* @param {string} newValue

Powered by Google App Engine
This is Rietveld 408576698