Set focus to search when opening add integration dialog (#4357)

* Set focus to search when opening add integration dialog

* Also add to flow form
This commit is contained in:
Bram Kragten 2019-12-18 16:35:20 +01:00 committed by Paulus Schoutsen
parent 2c57ab60f1
commit 609763e658
3 changed files with 13 additions and 0 deletions

View File

@ -16,6 +16,10 @@ import "@material/mwc-button";
class SearchInput extends LitElement {
@property() private filter?: string;
public focus() {
this.shadowRoot!.querySelector("paper-input")!.focus();
}
protected render(): TemplateResult | void {
return html`
<div class="search-container">

View File

@ -109,6 +109,7 @@ class StepFlowForm extends LitElement {
protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps);
setTimeout(() => this.shadowRoot!.querySelector("ha-form")!.focus(), 0);
this.addEventListener("keypress", (ev) => {
if (ev.keyCode === 13) {
this._submitStep();

View File

@ -101,6 +101,14 @@ class StepFlowPickHandler extends LitElement {
`;
}
protected firstUpdated(changedProps) {
super.firstUpdated(changedProps);
setTimeout(
() => this.shadowRoot!.querySelector("search-input")!.focus(),
0
);
}
protected updated(changedProps) {
super.updated(changedProps);
// Store the width so that when we search, box doesn't jump