mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 20:26:39 +00:00
Fix device and entity pickers clear (#4206)
* Fix device and entity pickers clear * Prevent combobox to open on clear
This commit is contained in:
parent
8b17b6ed1c
commit
c07b39ebde
@ -190,8 +190,9 @@ class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _clearValue() {
|
private _clearValue(ev: Event) {
|
||||||
this.value = "";
|
ev.stopPropagation();
|
||||||
|
this._setValue("");
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _value() {
|
private get _value() {
|
||||||
@ -206,14 +207,18 @@ class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
const newValue = ev.detail.value;
|
const newValue = ev.detail.value;
|
||||||
|
|
||||||
if (newValue !== this._value) {
|
if (newValue !== this._value) {
|
||||||
this.value = newValue;
|
this._setValue(newValue);
|
||||||
setTimeout(() => {
|
|
||||||
fireEvent(this, "value-changed", { value: newValue });
|
|
||||||
fireEvent(this, "change");
|
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _setValue(value: string) {
|
||||||
|
this.value = value;
|
||||||
|
setTimeout(() => {
|
||||||
|
fireEvent(this, "value-changed", { value });
|
||||||
|
fireEvent(this, "change");
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResult {
|
static get styles(): CSSResult {
|
||||||
return css`
|
return css`
|
||||||
paper-input > paper-icon-button {
|
paper-input > paper-icon-button {
|
||||||
|
@ -192,8 +192,9 @@ class HaEntityPicker extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _clearValue() {
|
private _clearValue(ev: Event) {
|
||||||
this.value = "";
|
ev.stopPropagation();
|
||||||
|
this._setValue("");
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _value() {
|
private get _value() {
|
||||||
@ -207,14 +208,18 @@ class HaEntityPicker extends LitElement {
|
|||||||
private _valueChanged(ev: PolymerChangedEvent<string>) {
|
private _valueChanged(ev: PolymerChangedEvent<string>) {
|
||||||
const newValue = ev.detail.value;
|
const newValue = ev.detail.value;
|
||||||
if (newValue !== this._value) {
|
if (newValue !== this._value) {
|
||||||
this.value = ev.detail.value;
|
this._setValue(newValue);
|
||||||
setTimeout(() => {
|
|
||||||
fireEvent(this, "value-changed", { value: this.value });
|
|
||||||
fireEvent(this, "change");
|
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _setValue(value: string) {
|
||||||
|
this.value = value;
|
||||||
|
setTimeout(() => {
|
||||||
|
fireEvent(this, "value-changed", { value });
|
||||||
|
fireEvent(this, "change");
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResult {
|
static get styles(): CSSResult {
|
||||||
return css`
|
return css`
|
||||||
paper-input > paper-icon-button {
|
paper-input > paper-icon-button {
|
||||||
|
@ -240,6 +240,11 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entityIdChanged() {
|
entityIdChanged() {
|
||||||
|
if (this._entityId === "") {
|
||||||
|
this._state = "";
|
||||||
|
this._stateAttributes = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
var state = this.hass.states[this._entityId];
|
var state = this.hass.states[this._entityId];
|
||||||
this._state = state.state;
|
this._state = state.state;
|
||||||
this._stateAttributes = safeDump(state.attributes);
|
this._stateAttributes = safeDump(state.attributes);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user