mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-29 12:16: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() {
|
||||
this.value = "";
|
||||
private _clearValue(ev: Event) {
|
||||
ev.stopPropagation();
|
||||
this._setValue("");
|
||||
}
|
||||
|
||||
private get _value() {
|
||||
@ -206,13 +207,17 @@ class HaDevicePicker extends SubscribeMixin(LitElement) {
|
||||
const newValue = ev.detail.value;
|
||||
|
||||
if (newValue !== this._value) {
|
||||
this.value = newValue;
|
||||
this._setValue(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
private _setValue(value: string) {
|
||||
this.value = value;
|
||||
setTimeout(() => {
|
||||
fireEvent(this, "value-changed", { value: newValue });
|
||||
fireEvent(this, "value-changed", { value });
|
||||
fireEvent(this, "change");
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static get styles(): CSSResult {
|
||||
return css`
|
||||
|
@ -192,8 +192,9 @@ class HaEntityPicker extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _clearValue() {
|
||||
this.value = "";
|
||||
private _clearValue(ev: Event) {
|
||||
ev.stopPropagation();
|
||||
this._setValue("");
|
||||
}
|
||||
|
||||
private get _value() {
|
||||
@ -207,13 +208,17 @@ class HaEntityPicker extends LitElement {
|
||||
private _valueChanged(ev: PolymerChangedEvent<string>) {
|
||||
const newValue = ev.detail.value;
|
||||
if (newValue !== this._value) {
|
||||
this.value = ev.detail.value;
|
||||
this._setValue(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
private _setValue(value: string) {
|
||||
this.value = value;
|
||||
setTimeout(() => {
|
||||
fireEvent(this, "value-changed", { value: this.value });
|
||||
fireEvent(this, "value-changed", { value });
|
||||
fireEvent(this, "change");
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static get styles(): CSSResult {
|
||||
return css`
|
||||
|
@ -240,6 +240,11 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
|
||||
}
|
||||
|
||||
entityIdChanged() {
|
||||
if (this._entityId === "") {
|
||||
this._state = "";
|
||||
this._stateAttributes = "";
|
||||
return;
|
||||
}
|
||||
var state = this.hass.states[this._entityId];
|
||||
this._state = state.state;
|
||||
this._stateAttributes = safeDump(state.attributes);
|
||||
|
Loading…
x
Reference in New Issue
Block a user