Skip to content

Convert hui-input-text-entity-row to TypeScript/LitElement#2050

Merged
balloob merged 4 commits intohome-assistant:devfrom
iantrich:ts-input-text
Nov 20, 2018
Merged

Convert hui-input-text-entity-row to TypeScript/LitElement#2050
balloob merged 4 commits intohome-assistant:devfrom
iantrich:ts-input-text

Conversation

@iantrich
Copy link
Copy Markdown
Member

No description provided.

@ghost ghost assigned iantrich Nov 14, 2018
@ghost ghost added the in progress label Nov 14, 2018
return;
}

this.hass!.callService("input_text", "set_value", {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should extract this to data/input_text.ts

return html``;
}

this._stateObj = this.hass.states[this._config.entity];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
hass: HomeAssistant,
entity: string,
value: string
) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should return the value (which is implicit if no { … } around lambda body. That way we can await until it's done.

@ghost ghost assigned balloob Nov 20, 2018
@balloob balloob merged commit b8f048d into home-assistant:dev Nov 20, 2018
@ghost ghost removed the in progress label Nov 20, 2018
@iantrich iantrich deleted the ts-input-text branch December 8, 2018 06:13
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants