|
86 | 86 | }
|
87 | 87 |
|
88 | 88 | render() {
|
89 |
| - return html` |
| 89 | + return this.stateObj ? html` |
90 | 90 | <ha-card .hass="${this._hass}" .config="${this._config}" class="background">
|
91 | 91 | ${this.state.title ? html`<div class="card-header">${this.state.title}</div>` : null}
|
92 | 92 | <div class="card-content">
|
|
98 | 98 | <div class="flex">
|
99 | 99 | ${Object.keys(this.state.buttons).map(this.renderButton.bind(this))}
|
100 | 100 | </div>` : null}
|
101 |
| - </ha-card>`; |
| 101 | + </ha-card>` : null; |
102 | 102 | }
|
103 | 103 |
|
104 | 104 | getCardSize() {
|
|
117 | 117 | }
|
118 | 118 |
|
119 | 119 | getText() {
|
120 |
| - return this.shadowRoot.querySelector(".textarea").value; |
| 120 | + return this.shadowRoot ? this.shadowRoot.querySelector(".textarea").value : ""; |
121 | 121 | }
|
122 | 122 |
|
123 | 123 | setText(val, entity_update) {
|
| 124 | + if(!this.shadowRoot) { |
| 125 | + return false; |
| 126 | + } |
| 127 | + |
124 | 128 | if(entity_update === true) {
|
125 | 129 | this.state.last_updated_text = val;
|
126 | 130 | }
|
| 131 | + |
127 | 132 | this.shadowRoot.querySelector(".textarea").value = val;
|
128 | 133 | this.resizeTextarea();
|
129 | 134 | this.updateCharactersInfoText();
|
|
136 | 141 |
|
137 | 142 | pasteText() {
|
138 | 143 | clearTimeout(this.state.autosave_timeout);
|
| 144 | + if(!this.shadowRoot) { |
| 145 | + return false; |
| 146 | + } |
| 147 | + |
139 | 148 | let elem = this.shadowRoot.querySelector(".textarea");
|
140 | 149 | if(elem) {
|
141 | 150 | elem.focus();
|
|
164 | 173 | }
|
165 | 174 |
|
166 | 175 | updateCharactersInfoText() {
|
| 176 | + if(!this.shadowRoot) { |
| 177 | + return false; |
| 178 | + } |
167 | 179 | let textLength = this.shadowRoot.querySelector(".textarea").value.length;
|
168 | 180 | let button_save = this.shadowRoot.querySelector("#button-save");
|
169 | 181 | let disable_button = false;
|
|
212 | 224 | }
|
213 | 225 |
|
214 | 226 | resizeTextarea() {
|
| 227 | + if(!this.shadowRoot) { |
| 228 | + return false; |
| 229 | + } |
215 | 230 | let textArea = this.shadowRoot.querySelector('.textarea');
|
216 | 231 | let textAreaComputedStyle = getComputedStyle(textArea);
|
217 | 232 | textArea.style.height = "auto";
|
|
369 | 384 | }
|
370 | 385 |
|
371 | 386 | 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