diff --git a/package.json b/package.json index bf01d8d..9bc6909 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tp/tp-textarea", - "version": "1.0.2", + "version": "1.0.3", "description": "", "main": "tp-textarea.js", "scripts": { diff --git a/tp-textarea.js b/tp-textarea.js index 9482fa6..e01f8de 100644 --- a/tp-textarea.js +++ b/tp-textarea.js @@ -110,11 +110,44 @@ class TpTextarea extends FormElement(DomQuery(ControlState(LitElement))) { connectedCallback() { super.connectedCallback(); this.addEventListener('input', this._onInput); + this._boundOnFocus = this._onFocus.bind(this); + this._boundOnBlur = this._onBlur.bind(this); } disconnectedCallback() { super.disconnectedCallback(); this.removeEventListener('input', this._onInput); + + if (this.textarea) { + this.textarea.removeEventListener('focus', this._boundOnFocus); + this.textarea.removeEventListener('blur', this._boundOnBlur); + } + } + + firstUpdated() { + super.firstUpdated(); + // ControlState sets tabindex="0" on the host, but the slotted