From a1bc748bc1d25259c248844ec1ee8fd19ffeae54 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Tue, 23 Aug 2022 23:45:44 -0400 Subject: [PATCH] Fix accessibility of settings and system navigation (#12845) --- src/components/ha-navigation-list.ts | 33 ++++++++++++------- .../core/ha-config-system-navigation.ts | 3 ++ .../config/dashboard/ha-config-navigation.ts | 17 +--------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/components/ha-navigation-list.ts b/src/components/ha-navigation-list.ts index f354e98001..048092379a 100644 --- a/src/components/ha-navigation-list.ts +++ b/src/components/ha-navigation-list.ts @@ -1,11 +1,12 @@ -import "@material/mwc-list/mwc-list"; -import "@material/mwc-list/mwc-list-item"; +import { ActionDetail } from "@material/mwc-list/mwc-list"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; import { customElement, property } from "lit/decorators"; +import { ifDefined } from "lit/directives/if-defined"; +import { navigate } from "../common/navigate"; import type { PageNavigation } from "../layouts/hass-tabs-subpage"; import type { HomeAssistant } from "../types"; -import "./ha-clickable-list-item"; import "./ha-icon-next"; +import "./ha-list-item"; import "./ha-svg-icon"; @customElement("ha-navigation-list") @@ -18,17 +19,22 @@ class HaNavigationList extends LitElement { @property({ type: Boolean }) public hasSecondary = false; + @property() public label?: string; + public render(): TemplateResult { return html` - + ${this.pages.map( (page) => html` -
` : ""} - + ` )} `; } - private _entryClicked(ev) { - ev.currentTarget.blur(); + private _handleListAction(ev: CustomEvent) { + const path = this.pages[ev.detail.index].path; + if (path.endsWith("#external-app-configuration")) { + this.hass.auth.external!.fireMessage({ type: "config_screen/show" }); + } else { + navigate(path); + } } static styles: CSSResultGroup = css` @@ -75,7 +86,7 @@ class HaNavigationList extends LitElement { .icon-background ha-svg-icon { color: #fff; } - ha-clickable-list-item { + ha-list-item { cursor: pointer; font-size: var(--navigation-list-item-title-font-size); padding: var(--navigation-list-item-padding) 0; diff --git a/src/panels/config/core/ha-config-system-navigation.ts b/src/panels/config/core/ha-config-system-navigation.ts index 210e9b3bf3..e69948c657 100644 --- a/src/panels/config/core/ha-config-system-navigation.ts +++ b/src/panels/config/core/ha-config-system-navigation.ts @@ -137,6 +137,9 @@ class HaConfigSystemNavigation extends LitElement { .narrow=${this.narrow} .pages=${pages} hasSecondary + .label=${this.hass.localize( + "ui.panel.config.dashboard.system.main" + )} > diff --git a/src/panels/config/dashboard/ha-config-navigation.ts b/src/panels/config/dashboard/ha-config-navigation.ts index 7a293b4225..39e098b5da 100644 --- a/src/panels/config/dashboard/ha-config-navigation.ts +++ b/src/panels/config/dashboard/ha-config-navigation.ts @@ -60,26 +60,11 @@ class HaConfigNavigation extends LitElement { .hass=${this.hass} .narrow=${this.narrow} .pages=${pages} - @click=${this._entryClicked} + .label=${this.hass.localize("panel.config")} > `; } - private _entryClicked(ev) { - const anchor = ev - .composedPath() - .find((n) => (n as HTMLElement).tagName === "A") as - | HTMLAnchorElement - | undefined; - - if (anchor?.href?.endsWith("#external-app-configuration")) { - ev.preventDefault(); - this.hass.auth.external!.fireMessage({ - type: "config_screen/show", - }); - } - } - static styles: CSSResultGroup = css` ha-navigation-list { --navigation-list-item-title-font-size: 16px;