Convert hui-input-text-entity-row to TypeScript/LitElement#2050
Convert hui-input-text-entity-row to TypeScript/LitElement#2050balloob merged 4 commits intohome-assistant:devfrom
Conversation
| return; | ||
| } | ||
|
|
||
| this.hass!.callService("input_text", "set_value", { |
There was a problem hiding this comment.
I think that we should extract this to data/input_text.ts
| return html``; | ||
| } | ||
|
|
||
| this._stateObj = this.hass.states[this._config.entity]; |
There was a problem hiding this comment.
No reason for this to be an instance variable, is it? Can just be a local one?
| } | ||
|
|
||
| private get _value(): PaperInputElement { | ||
| return this.shadowRoot!.querySelector(".value") as PaperInputElement; |
There was a problem hiding this comment.
No need to add a class, you could just query for paper-input as there is only one in this shadow DOM.
The nice thing about ShadowDOM is that we have a mini piece of DOM that is only whatever we put in our template. No need to wiggle around with class selectors etc.
| `; | ||
| } | ||
|
|
||
| private get _value(): PaperInputElement { |
There was a problem hiding this comment.
This name is a bit weird, as you are returning an input element, not a value. I would call it inputEl
Does anyone know why line 74 seemingly doesn't fire when the value hasn't changed? I think we should blur regardless if the value changed or not on "enter" but only seems to work when setValue is called
src/data/input_text.ts
Outdated
| hass: HomeAssistant, | ||
| entity: string, | ||
| value: string | ||
| ) => { |
There was a problem hiding this comment.
we should return the value (which is implicit if no { … } around lambda body. That way we can await until it's done.
No description provided.