From 0729aaacb8f9acfe0519fe410e1c537a39574549 Mon Sep 17 00:00:00 2001 From: Wendelin <12148533+wendevlin@users.noreply.github.com> Date: Tue, 6 May 2025 11:00:37 +0200 Subject: [PATCH] Revert "Keyboard accessible panel sorting" (#25331) --- src/components/ha-sidebar.ts | 71 +++----------------------- src/resources/ha-sidebar-edit-style.ts | 2 +- src/translations/en.json | 4 +- 3 files changed, 9 insertions(+), 68 deletions(-) diff --git a/src/components/ha-sidebar.ts b/src/components/ha-sidebar.ts index 3f48666754..19c4a8d633 100644 --- a/src/components/ha-sidebar.ts +++ b/src/components/ha-sidebar.ts @@ -52,7 +52,6 @@ import "./user/ha-user-badge"; import "./ha-md-list"; import "./ha-md-list-item"; import type { HaMdListItem } from "./ha-md-list-item"; -import { showPromptDialog } from "../dialogs/generic/show-dialog-box"; const SHOW_AFTER_SPACER = ["config", "developer-tools"]; @@ -425,12 +424,8 @@ class HaSidebar extends SubscribeMixin(LitElement) { `; } - private _renderPanels( - panels: PanelInfo[], - selectedPanel: string, - orderable = false - ) { - return panels.map((panel, idx) => + private _renderPanels(panels: PanelInfo[], selectedPanel: string) { + return panels.map((panel) => this._renderPanel( panel.url_path, panel.url_path === this.hass.defaultPanel @@ -442,8 +437,7 @@ class HaSidebar extends SubscribeMixin(LitElement) { : panel.url_path in PANEL_ICONS ? PANEL_ICONS[panel.url_path] : undefined, - selectedPanel, - orderable ? idx : null + selectedPanel ) ); } @@ -453,8 +447,7 @@ class HaSidebar extends SubscribeMixin(LitElement) { title: string | null, icon: string | null | undefined, iconPath: string | null | undefined, - selectedPanel: string, - index: number | null + selectedPanel: string ) { return urlPath === "config" ? this._renderConfiguration(title, selectedPanel) @@ -470,20 +463,8 @@ class HaSidebar extends SubscribeMixin(LitElement) { ? html`` : html``} ${title} - ${index != null - ? html` -
${index + 1}
-
` - : nothing} ${this.editMode - ? html`
${this._renderPanels(beforeSpacer, selectedPanel, true)}
+ >
${this._renderPanels(beforeSpacer, selectedPanel)}
${this._renderSpacer()}${this._renderHiddenPanels()} `; @@ -712,28 +690,6 @@ class HaSidebar extends SubscribeMixin(LitElement) { fireEvent(this, "hass-edit-sidebar", { editMode: false }); } - private async _changePosition(ev): Promise { - ev.preventDefault(); - const oldIndex = (ev.currentTarget as any).index as number; - const name = ((ev.currentTarget as any).title as string) || ""; - - const positionString = await showPromptDialog(this, { - title: this.hass!.localize("ui.sidebar.change_position"), - text: this.hass!.localize("ui.sidebar.change_position_dialog_text", { - name, - }), - inputType: "number", - inputMin: "1", - placeholder: String(oldIndex + 1), - }); - - if (!positionString) return; - const position = parseInt(positionString); - if (isNaN(position)) return; - const newIndex = Math.max(0, position - 1); - this._panelMove(oldIndex, newIndex); - } - private async _hidePanel(ev: Event) { ev.preventDefault(); const panel = (ev.currentTarget as any).panel; @@ -984,7 +940,7 @@ class HaSidebar extends SubscribeMixin(LitElement) { ha-md-list-item .item-text { display: none; - max-width: 100%; + max-width: calc(100% - 56px); font-weight: 500; font-size: 14px; } @@ -1015,19 +971,6 @@ class HaSidebar extends SubscribeMixin(LitElement) { color: var(--text-accent-color, var(--text-primary-color)); } - .position-badge { - display: block; - width: 24px; - line-height: 24px; - box-sizing: border-box; - border-radius: 50%; - font-weight: 500; - text-align: center; - font-size: 14px; - background-color: var(--app-header-edit-background-color, #455a64); - color: var(--app-header-edit-text-color, white); - } - ha-svg-icon + .badge { position: absolute; top: 4px; diff --git a/src/resources/ha-sidebar-edit-style.ts b/src/resources/ha-sidebar-edit-style.ts index 10dc29f913..efd4ddee10 100644 --- a/src/resources/ha-sidebar-edit-style.ts +++ b/src/resources/ha-sidebar-edit-style.ts @@ -58,7 +58,7 @@ export const sidebarEditStyle = css` } :host([expanded]) .hide-panel { - display: inline-block; + display: block; } :host([expanded]) .show-panel { diff --git a/src/translations/en.json b/src/translations/en.json index d3da5cbb65..6e4810e682 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -2018,9 +2018,7 @@ "sidebar_toggle": "Sidebar toggle", "done": "Done", "hide_panel": "Hide panel", - "show_panel": "Show panel", - "change_position": "Change panel position", - "change_position_dialog_text": "What position do you want to move your ''{name}'' panel to?" + "show_panel": "Show panel" }, "panel": { "my": {