diff --git a/bower.json b/bower.json index 667894c..6621b73 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "strolch-wc-debounced-input", "description": "Strolch WebComponent Debounced Input", - "version": "0.1.1", + "version": "0.1.2", "authors": [ "Robert von Burg" ], diff --git a/strolch-wc-debounced-input.html b/strolch-wc-debounced-input.html index cb0c75f..c06e730 100644 --- a/strolch-wc-debounced-input.html +++ b/strolch-wc-debounced-input.html @@ -106,14 +106,7 @@ observeInput: function (newValue, oldValue) { this.debounce("inputDebounce", function () { - // save the previous value so it may be reset - this.set("prevDebouncedInput", this.debouncedInput); - // set the debounced input after delay - this.set("debouncedInput", newValue); - this.fire('strolch-wc-debounced-input-changed', { - input: newValue, - enterPressed: false - }); + this._setInput(newValue, false); }, 500); }, @@ -124,21 +117,27 @@ // if enter was pressed if (event.keyCode === 13) { this.debounce("inputDebounce", function () { - // save the previous value so it may be reset - this.set("prevDebouncedInput", this.debouncedInput); - // set the debounced input after delay - this.set("debouncedInput", this.input); - this.fire('strolch-wc-debounced-input-changed', { - input: this.input, - enterPressed: true - }); + this._setInput(this.input, true); }, 200); } }, + _setInput: function (newValue, enterPressed) { + // save the previous value so it may be reset + this.set("prevDebouncedInput", this.debouncedInput); + // set the debounced input after delay + this.set("debouncedInput", newValue); + this.fire('strolch-wc-debounced-input-changed', { + input: newValue, + enterPressed: enterPressed + }); + }, + - onClearTapped: function (event) { + onClearTapped: function () { this.setInputTerm(""); + this.cancelDebouncer("inputDebounce"); + this._setInput("", false); }, undoLastInput: function () { // apply the last debounced input