Skip to content

Commit f4d019d

Browse files
committed
Update to 1.0.3. Fix #3
1 parent 014d91f commit f4d019d

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## 1.0.3
5+
- Fixed HA 0.116 compatibility issue (#3)
6+
7+
## 1.0.2
8+
- Clear text bugfix
9+
10+
## 1.0.1
11+
- Readme + description
12+
413
## 1.0.0
514

615
- **Initial release**

lovelace-multiline-text-input-card.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
}
8787

8888
render() {
89-
return html`
89+
return this.stateObj ? html`
9090
<ha-card .hass="${this._hass}" .config="${this._config}" class="background">
9191
${this.state.title ? html`<div class="card-header">${this.state.title}</div>` : null}
9292
<div class="card-content">
@@ -98,7 +98,7 @@
9898
<div class="flex">
9999
${Object.keys(this.state.buttons).map(this.renderButton.bind(this))}
100100
</div>` : null}
101-
</ha-card>`;
101+
</ha-card>` : null;
102102
}
103103

104104
getCardSize() {
@@ -117,13 +117,18 @@
117117
}
118118

119119
getText() {
120-
return this.shadowRoot.querySelector(".textarea").value;
120+
return this.shadowRoot ? this.shadowRoot.querySelector(".textarea").value : "";
121121
}
122122

123123
setText(val, entity_update) {
124+
if(!this.shadowRoot) {
125+
return false;
126+
}
127+
124128
if(entity_update === true) {
125129
this.state.last_updated_text = val;
126130
}
131+
127132
this.shadowRoot.querySelector(".textarea").value = val;
128133
this.resizeTextarea();
129134
this.updateCharactersInfoText();
@@ -136,6 +141,10 @@
136141

137142
pasteText() {
138143
clearTimeout(this.state.autosave_timeout);
144+
if(!this.shadowRoot) {
145+
return false;
146+
}
147+
139148
let elem = this.shadowRoot.querySelector(".textarea");
140149
if(elem) {
141150
elem.focus();
@@ -164,6 +173,9 @@
164173
}
165174

166175
updateCharactersInfoText() {
176+
if(!this.shadowRoot) {
177+
return false;
178+
}
167179
let textLength = this.shadowRoot.querySelector(".textarea").value.length;
168180
let button_save = this.shadowRoot.querySelector("#button-save");
169181
let disable_button = false;
@@ -212,6 +224,9 @@
212224
}
213225

214226
resizeTextarea() {
227+
if(!this.shadowRoot) {
228+
return false;
229+
}
215230
let textArea = this.shadowRoot.querySelector('.textarea');
216231
let textAreaComputedStyle = getComputedStyle(textArea);
217232
textArea.style.height = "auto";
@@ -369,4 +384,4 @@
369384
}
370385

371386
customElements.define('lovelace-multiline-text-input-card', LovelaceMultilineTextInput);
372-
})(window.LitElement || Object.getPrototypeOf(customElements.get("hui-view")));
387+
})(window.LitElement || Object.getPrototypeOf(customElements.get("hui-masonry-view") || customElements.get("hui-view")));

0 commit comments

Comments
 (0)