mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 02:49:51 +00:00
Fix pickers not getting focus (#14068)
* fix focus pickers * await nextRender instead of setTimeout * use bram's code * Update src/components/ha-target-picker.ts Co-authored-by: Steve Repsher <steverep@users.noreply.github.com> Co-authored-by: Steve Repsher <steverep@users.noreply.github.com>
This commit is contained in:
@@ -221,12 +221,14 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
||||
}
|
||||
);
|
||||
|
||||
public open() {
|
||||
this.comboBox?.open();
|
||||
public async open() {
|
||||
await this.updateComplete;
|
||||
await this.comboBox?.open();
|
||||
}
|
||||
|
||||
public focus() {
|
||||
this.comboBox?.focus();
|
||||
public async focus() {
|
||||
await this.updateComplete;
|
||||
await this.comboBox?.focus();
|
||||
}
|
||||
|
||||
public hassSubscribe(): UnsubscribeFunc[] {
|
||||
@@ -246,7 +248,7 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
||||
protected updated(changedProps: PropertyValues) {
|
||||
if (
|
||||
(!this._init && this.devices && this.areas && this.entities) ||
|
||||
(changedProps.has("_opened") && this._opened)
|
||||
(this._init && changedProps.has("_opened") && this._opened)
|
||||
) {
|
||||
this._init = true;
|
||||
(this.comboBox as any).items = this._getDevices(
|
||||
@@ -262,9 +264,6 @@ export class HaDevicePicker extends SubscribeMixin(LitElement) {
|
||||
}
|
||||
|
||||
protected render(): TemplateResult {
|
||||
if (!this.devices || !this.areas || !this.entities) {
|
||||
return html``;
|
||||
}
|
||||
return html`
|
||||
<ha-combo-box
|
||||
.hass=${this.hass}
|
||||
|
||||
Reference in New Issue
Block a user