diff --git a/src/components/data-table/ha-data-table.ts b/src/components/data-table/ha-data-table.ts index 9a89230db0..b611ccacb8 100644 --- a/src/components/data-table/ha-data-table.ts +++ b/src/components/data-table/ha-data-table.ts @@ -16,6 +16,7 @@ import { styleMap } from "lit/directives/style-map"; import memoizeOne from "memoize-one"; import { STRINGS_SEPARATOR_DOT } from "../../common/const"; import { restoreScroll } from "../../common/decorators/restore-scroll"; +import { deepActiveElement } from "../../common/dom/deep-active-element"; import { fireEvent } from "../../common/dom/fire_event"; import type { HASSDomCurrentTargetEvent, @@ -265,11 +266,13 @@ export class HaDataTable extends LitElement { this.style.removeProperty("--table-row-width"); } + const activeElement = deepActiveElement(); + if ( changedProps.has("selectable") || (!this.autoHeight && - document.activeElement && - AUTO_FOCUS_ALLOWED_ACTIVE_TAGS.includes(document.activeElement.tagName)) + activeElement && + AUTO_FOCUS_ALLOWED_ACTIVE_TAGS.includes(activeElement.tagName)) ) { this._focusScroller(); } diff --git a/src/panels/config/integrations/ha-config-integrations-dashboard.ts b/src/panels/config/integrations/ha-config-integrations-dashboard.ts index 8a7ac67312..05ecf43153 100644 --- a/src/panels/config/integrations/ha-config-integrations-dashboard.ts +++ b/src/panels/config/integrations/ha-config-integrations-dashboard.ts @@ -16,6 +16,7 @@ import { navigate } from "../../../common/navigate"; import { caseInsensitiveStringCompare } from "../../../common/string/compare"; import { extractSearchParam } from "../../../common/url/search-params"; import { nextRender } from "../../../common/util/render-status"; +import { deepActiveElement } from "../../../common/dom/deep-active-element"; import "../../../components/ha-button"; import "../../../components/ha-checkbox"; import "../../../components/ha-dropdown"; @@ -428,6 +429,17 @@ class HaConfigIntegrationsDashboard extends KeyboardShortcutMixin( } if (this.configEntries && this.configEntriesInProgress) { + const activeElement = deepActiveElement(); + + if ( + activeElement instanceof HTMLInputElement || + activeElement instanceof HTMLTextAreaElement || + activeElement instanceof HTMLSelectElement || + (activeElement as HTMLElement | null)?.isContentEditable + ) { + return; + } + this._tabsSubpage?.focusContentScroller(); } }