diff --git a/package.json b/package.json index b81e1ad..63f048f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tp/tp-number-input", - "version": "1.1.0", + "version": "1.1.1", "description": "", "main": "tp-number-input.js", "scripts": { diff --git a/tp-number-input.js b/tp-number-input.js index c974096..fde76a4 100644 --- a/tp-number-input.js +++ b/tp-number-input.js @@ -146,7 +146,7 @@ class TpNumberInput extends FormElement(EventHelpers(DomQuery(LitElement))) { } if (changes.has('value') || changes.has('min') || changes.has('max') || changes.has('suffix') || changes.has('ignoreSuffix') || changes.has('timeMode')) { - this._updateValue(this.value); + this._updateValue(this.value, true); } } @@ -325,17 +325,7 @@ class TpNumberInput extends FormElement(EventHelpers(DomQuery(LitElement))) { } } - _internValueChanged(val) { - if(val === '') return; - - if(this.timeMode) { - this._timeValueChanged(val); - } else { - this._updateValue(val); - } - } - - _updateValue(val) { + _updateValue(val, skipEvent) { if(this.timeMode) return; const oldValue = this.value; @@ -344,11 +334,7 @@ class TpNumberInput extends FormElement(EventHelpers(DomQuery(LitElement))) { this.value = this.specialMin; this.$.input.value = this.value; if (oldValue !== this.value && this._isConnected) { - this.dispatchEvent(new CustomEvent('number-changed', { - detail: { value: this.value }, - bubbles: true, - composed: true - })); + if (!skipEvent) this.dispatchEvent(new CustomEvent('number-changed', { detail: { value: this.value }, bubbles: true, composed: true })); } return; } @@ -365,11 +351,7 @@ class TpNumberInput extends FormElement(EventHelpers(DomQuery(LitElement))) { this.value = this.specialMin; this.$.input.value = this.value; if (oldValue !== this.value && this._isConnected) { - this.dispatchEvent(new CustomEvent('number-changed', { - detail: { value: this.value }, - bubbles: true, - composed: true - })); + if (!skipEvent) this.dispatchEvent(new CustomEvent('number-changed', { detail: { value: this.value }, bubbles: true, composed: true })); } return; } @@ -380,11 +362,7 @@ class TpNumberInput extends FormElement(EventHelpers(DomQuery(LitElement))) { this.$.input.value = !!this.suffix ? val + this.suffix : val; if (oldValue !== this.value && this._isConnected) { - this.dispatchEvent(new CustomEvent('number-changed', { - detail: { value: this.value }, - bubbles: true, - composed: true - })); + if (!skipEvent) this.dispatchEvent(new CustomEvent('number-changed', { detail: { value: this.value }, bubbles: true, composed: true })); } } }