Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions src/components/ha-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import memoizeOne from "memoize-one";
import { LocalStorage } from "../common/decorators/local-storage";
import { fireEvent } from "../common/dom/fire_event";
import { computeDomain } from "../common/entity/compute_domain";
import { navigate } from "../common/navigate";
import { compare } from "../common/string/compare";
import { computeRTL } from "../common/util/compute_rtl";
import { ActionHandlerDetail } from "../data/lovelace";
Expand Down Expand Up @@ -235,7 +234,14 @@ class HaSidebar extends LitElement {
</style>
`
: ""}
<div class="menu">
<div
class="menu"
@action=${this._handleAction}
.actionHandler=${actionHandler({
hasHold: !this._editMode,
disabled: this._editMode,
})}
>
${!this.narrow
? html`
<mwc-icon-button
Expand Down Expand Up @@ -266,11 +272,6 @@ class HaSidebar extends LitElement {
@focusout=${this._listboxFocusOut}
@scroll=${this._listboxScroll}
@keydown=${this._listboxKeydown}
@action=${this._handleAction}
.actionHandler=${actionHandler({
hasHold: !this._editMode,
disabled: this._editMode,
})}
>
${this._editMode
? html`<div id="sortable">
Expand Down Expand Up @@ -322,7 +323,7 @@ class HaSidebar extends LitElement {
)}
href="#external-app-configuration"
tabindex="-1"
@panel-tap=${this._handleExternalAppConfiguration}
@click=${this._handleExternalAppConfiguration}
@mouseenter=${this._itemMouseEnter}
@mouseleave=${this._itemMouseLeave}
>
Expand Down Expand Up @@ -479,8 +480,7 @@ class HaSidebar extends LitElement {
}

private async _handleAction(ev: CustomEvent<ActionHandlerDetail>) {
if (ev.detail.action === "tap") {
fireEvent(ev.target as HTMLElement, "panel-tap");
if (ev.detail.action !== "hold") {
return;
}

Expand Down Expand Up @@ -660,13 +660,6 @@ class HaSidebar extends LitElement {
);
}

private async _handlePanelTap(ev: Event) {
const path = __DEMO__
? (ev.currentTarget as HTMLAnchorElement).getAttribute("href")!
: (ev.currentTarget as HTMLAnchorElement).href;
navigate(this, path);
}

private _renderPanel(
urlPath: string,
title: string | null,
Expand All @@ -679,7 +672,6 @@ class HaSidebar extends LitElement {
href=${`/${urlPath}`}
data-panel=${urlPath}
tabindex="-1"
@panel-tap=${this._handlePanelTap}
@mouseenter=${this._itemMouseEnter}
@mouseleave=${this._itemMouseLeave}
>
Expand Down Expand Up @@ -989,8 +981,4 @@ declare global {
interface HTMLElementTagNameMap {
"ha-sidebar": HaSidebar;
}

interface HASSDomEvents {
"panel-tap": undefined;
}
}