mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Filter out invalid text input for input_text
(#10797)
This commit is contained in:
parent
911d322aac
commit
f164d21c44
@ -1,7 +1,7 @@
|
||||
import { PaperInputElement } from "@polymer/paper-input/paper-input";
|
||||
import { html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { UNAVAILABLE } from "../../../data/entity";
|
||||
import { UNAVAILABLE, UNAVAILABLE_STATES } from "../../../data/entity";
|
||||
import { setValue } from "../../../data/input_text";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { hasConfigOrEntityChanged } from "../common/has-changed";
|
||||
@ -67,6 +67,12 @@ class HuiInputTextEntityRow extends LitElement implements LovelaceRow {
|
||||
const element = this._inputEl;
|
||||
const stateObj = this.hass!.states[this._config!.entity];
|
||||
|
||||
// Filter out invalid text states
|
||||
if (element.value && UNAVAILABLE_STATES.includes(element.value)) {
|
||||
element.value = stateObj.state;
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.value !== stateObj.state) {
|
||||
setValue(this.hass!, stateObj.entity_id, element.value!);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user