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

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

Issue 2057353002: WebUI: cr-search-field, do not call delegate if search query did not change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments. 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 3657f79f2600b74d83b7b4e4f754df3d87c44b32..a19adc25e0885fddc4848de0badadf5d21236d6d 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
@@ -38,6 +38,12 @@ var CrSearchFieldBehavior = {
},
hasSearchText: Boolean,
+
+ /** @private */
+ lastValue_: {
+ type: String,
+ value: '',
+ },
},
/**
@@ -74,9 +80,14 @@ var CrSearchFieldBehavior = {
},
onSearchTermSearch: function() {
- this.hasSearchText = this.getValue() != '';
+ var newValue = this.getValue();
+ if (newValue == this.lastValue_)
+ return;
+
+ this.hasSearchText = newValue != '';
if (this.delegate_)
- this.delegate_.onSearchTermSearch(this.getValue());
+ this.delegate_.onSearchTermSearch(newValue);
+ this.lastValue_ = newValue;
},
onSearchTermKeydown: function(e) {
« 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