mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 02:38:53 +00:00
Add iOS-specific autofocus handling in HaWaDialog
This commit is contained in:
@@ -13,6 +13,7 @@ import { fireEvent } from "../common/dom/fire_event";
|
|||||||
import { ScrollableFadeMixin } from "../mixins/scrollable-fade-mixin";
|
import { ScrollableFadeMixin } from "../mixins/scrollable-fade-mixin";
|
||||||
import { haStyleScrollbar } from "../resources/styles";
|
import { haStyleScrollbar } from "../resources/styles";
|
||||||
import type { HomeAssistant } from "../types";
|
import type { HomeAssistant } from "../types";
|
||||||
|
import { isIosApp } from "../util/is_ios";
|
||||||
import "./ha-dialog-header";
|
import "./ha-dialog-header";
|
||||||
import "./ha-icon-button";
|
import "./ha-icon-button";
|
||||||
|
|
||||||
@@ -184,6 +185,21 @@ export class HaWaDialog extends ScrollableFadeMixin(LitElement) {
|
|||||||
await this.updateComplete;
|
await this.updateComplete;
|
||||||
|
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
|
if (isIosApp(this.hass)) {
|
||||||
|
const element = this.querySelector("[autofocus]");
|
||||||
|
if (element !== null) {
|
||||||
|
if (!element.id) {
|
||||||
|
element.id = "ha-wa-dialog-autofocus";
|
||||||
|
}
|
||||||
|
this.hass.auth.external!.fireMessage({
|
||||||
|
type: "focus_element",
|
||||||
|
payload: {
|
||||||
|
element_id: element.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
(this.querySelector("[autofocus]") as HTMLElement | null)?.focus();
|
(this.querySelector("[autofocus]") as HTMLElement | null)?.focus();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user