Skip to content

Commit

Permalink
Focus search input on integrations dashboard when using search shotcut (
Browse files Browse the repository at this point in the history
#23647)

Focus search input on integrations dashboard when using search shortcut
  • Loading branch information
jpbede authored Jan 8, 2025
1 parent f8264e4 commit 712817d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/panels/config/integrations/ha-config-integrations-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Fuse from "fuse.js";
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
import type { CSSResultGroup, PropertyValues } from "lit";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
import { customElement, property, query, state } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import memoizeOne from "memoize-one";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
Expand Down Expand Up @@ -70,6 +70,7 @@ import "./ha-integration-overflow-menu";
import { showAddIntegrationDialog } from "./show-add-integration-dialog";
import { fetchEntitySourcesWithCache } from "../../../data/entity_sources";
import type { ImprovDiscoveredDevice } from "../../../external_app/external_messaging";
import { KeyboardShortcutMixin } from "../../../mixins/keyboard-shortcut-mixin";

export interface ConfigEntryExtended extends Omit<ConfigEntry, "entry_id"> {
entry_id?: string;
Expand All @@ -90,7 +91,9 @@ const groupByIntegration = (
return result;
};
@customElement("ha-config-integrations-dashboard")
class HaConfigIntegrationsDashboard extends SubscribeMixin(LitElement) {
class HaConfigIntegrationsDashboard extends KeyboardShortcutMixin(
SubscribeMixin(LitElement)
) {
@property({ attribute: false }) public hass!: HomeAssistant;

@property({ type: Boolean, reflect: true }) public narrow = false;
Expand Down Expand Up @@ -135,6 +138,8 @@ class HaConfigIntegrationsDashboard extends SubscribeMixin(LitElement) {
[integration: string]: IntegrationLogInfo;
};

@query("search-input-outlined") private _searchInput!: HTMLElement;

public disconnectedCallback(): void {
super.disconnectedCallback();
window.removeEventListener(
Expand Down Expand Up @@ -946,6 +951,12 @@ class HaConfigIntegrationsDashboard extends SubscribeMixin(LitElement) {
});
}

protected supportedShortcuts(): SupportedShortcuts {
return {
f: () => this._searchInput.focus(),
};
}

static get styles(): CSSResultGroup {
return [
haStyle,
Expand Down

0 comments on commit 712817d

Please sign in to comment.