mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Don't update device picker while open (#7903)
This commit is contained in:
parent
34eb4d974d
commit
b79c03433e
@ -12,6 +12,8 @@ import {
|
|||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
property,
|
property,
|
||||||
|
PropertyValues,
|
||||||
|
query,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
} from "lit-element";
|
} from "lit-element";
|
||||||
import memoizeOne from "memoize-one";
|
import memoizeOne from "memoize-one";
|
||||||
@ -111,6 +113,8 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
@property({ type: Boolean })
|
@property({ type: Boolean })
|
||||||
private _opened?: boolean;
|
private _opened?: boolean;
|
||||||
|
|
||||||
|
@query("vaadin-combo-box-light", true) private _comboBox!: HTMLElement;
|
||||||
|
|
||||||
public open() {
|
public open() {
|
||||||
this.updateComplete.then(() => {
|
this.updateComplete.then(() => {
|
||||||
(this.shadowRoot?.querySelector("vaadin-combo-box-light") as any)?.open();
|
(this.shadowRoot?.querySelector("vaadin-combo-box-light") as any)?.open();
|
||||||
@ -246,25 +250,29 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected updated(changedProps: PropertyValues) {
|
||||||
if (!this.devices || !this.areas || !this.entities) {
|
if (changedProps.has("_opened") && this._opened) {
|
||||||
return html``;
|
(this._comboBox as any).items = this._getDevices(
|
||||||
}
|
this.devices!,
|
||||||
const devices = this._getDevices(
|
this.areas!,
|
||||||
this.devices,
|
this.entities!,
|
||||||
this.areas,
|
|
||||||
this.entities,
|
|
||||||
this.includeDomains,
|
this.includeDomains,
|
||||||
this.excludeDomains,
|
this.excludeDomains,
|
||||||
this.includeDeviceClasses,
|
this.includeDeviceClasses,
|
||||||
this.deviceFilter
|
this.deviceFilter
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected render(): TemplateResult {
|
||||||
|
if (!this.devices || !this.areas || !this.entities) {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
return html`
|
return html`
|
||||||
<vaadin-combo-box-light
|
<vaadin-combo-box-light
|
||||||
item-value-path="id"
|
item-value-path="id"
|
||||||
item-id-path="id"
|
item-id-path="id"
|
||||||
item-label-path="name"
|
item-label-path="name"
|
||||||
.items=${devices}
|
|
||||||
.value=${this._value}
|
.value=${this._value}
|
||||||
.renderer=${rowRenderer}
|
.renderer=${rowRenderer}
|
||||||
@opened-changed=${this._openedChanged}
|
@opened-changed=${this._openedChanged}
|
||||||
@ -296,8 +304,6 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
</ha-icon-button>
|
</ha-icon-button>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
${devices.length > 0
|
|
||||||
? html`
|
|
||||||
<ha-icon-button
|
<ha-icon-button
|
||||||
aria-label=${this.hass.localize(
|
aria-label=${this.hass.localize(
|
||||||
"ui.components.device-picker.show_devices"
|
"ui.components.device-picker.show_devices"
|
||||||
@ -308,8 +314,6 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
|||||||
>
|
>
|
||||||
Toggle
|
Toggle
|
||||||
</ha-icon-button>
|
</ha-icon-button>
|
||||||
`
|
|
||||||
: ""}
|
|
||||||
</paper-input>
|
</paper-input>
|
||||||
</vaadin-combo-box-light>
|
</vaadin-combo-box-light>
|
||||||
`;
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user