Fix device and entity pickers clear (#4206)

* Fix device and entity pickers clear

* Prevent combobox to open on clear
This commit is contained in:
Bram Kragten
2019-11-10 22:25:07 +01:00
committed by Paulus Schoutsen
parent 8b17b6ed1c
commit c07b39ebde
3 changed files with 29 additions and 14 deletions

View File

@@ -192,8 +192,9 @@ class HaEntityPicker extends LitElement {
`;
}
private _clearValue() {
this.value = "";
private _clearValue(ev: Event) {
ev.stopPropagation();
this._setValue("");
}
private get _value() {
@@ -207,14 +208,18 @@ class HaEntityPicker extends LitElement {
private _valueChanged(ev: PolymerChangedEvent<string>) {
const newValue = ev.detail.value;
if (newValue !== this._value) {
this.value = ev.detail.value;
setTimeout(() => {
fireEvent(this, "value-changed", { value: this.value });
fireEvent(this, "change");
}, 0);
this._setValue(newValue);
}
}
private _setValue(value: string) {
this.value = value;
setTimeout(() => {
fireEvent(this, "value-changed", { value });
fireEvent(this, "change");
}, 0);
}
static get styles(): CSSResult {
return css`
paper-input > paper-icon-button {