commit 4727d73b3fc26a8b3b430bb6b85cf04fef62b90a
parent a46c910f6088ba59ae1aa7117eca8cde4c511053
Author: Sergey Orlov <wladimirych@gmail.com>
Date: Wed, 12 Aug 2020 22:54:32 +0200
search: Do not send request when user clicks clear button. Fixes #499
Diffstat:
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/lib/leaflet.control.search/index.js b/src/lib/leaflet.control.search/index.js
@@ -89,14 +89,18 @@ class SearchViewModel {
}
onControlHasFocusChange(active) {
- if (active) {
- this.maybeRequestSearch(this.query());
- } else {
+ if (!active) {
this.items.removeAll();
this.error(null);
}
}
+ onInputHasFocusChange(active) {
+ if (active) {
+ this.maybeRequestSearch(this.query());
+ }
+ }
+
onClearClick() {
this.query('');
this.inputHasFocus(true);
@@ -200,6 +204,7 @@ class SearchViewModel {
this.query.subscribe(this.onQueryChange.bind(this));
this.showResults.subscribe(this.onShowResults.bind(this));
this.controlHasFocus.subscribe(this.onControlHasFocusChange.bind(this));
+ this.inputHasFocus.subscribe(this.onInputHasFocusChange.bind(this));
}
}