From 1e0f7d9629cf007848f7b8dc69042ec558f46615 Mon Sep 17 00:00:00 2001
From: Simon Lamon <32477463+silamon@users.noreply.github.com>
Date: Tue, 9 Apr 2024 14:10:59 +0200
Subject: [PATCH] Don't display keyboard shortcut hints if keyboard shortcuts
are disabled (#20456)
* Shortcut hints
* Prettier
---
.../config/dashboard/ha-config-dashboard.ts | 17 ++++++++++++++---
.../state/developer-tools-state.ts | 8 +++++---
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/panels/config/dashboard/ha-config-dashboard.ts b/src/panels/config/dashboard/ha-config-dashboard.ts
index 918b8c888e..9e4562f9a4 100644
--- a/src/panels/config/dashboard/ha-config-dashboard.ts
+++ b/src/panels/config/dashboard/ha-config-dashboard.ts
@@ -93,10 +93,19 @@ const randomTip = (hass: HomeAssistant, narrow: boolean) => {
weight: 2,
narrow: true,
},
- { content: hass.localize("ui.tips.key_c_hint"), weight: 1, narrow: false },
- { content: hass.localize("ui.tips.key_m_hint"), weight: 1, narrow: false },
];
+ if (hass?.enableShortcuts) {
+ tips.push(
+ {
+ content: hass.localize("ui.tips.key_c_hint"),
+ weight: 1,
+ narrow: false,
+ },
+ { content: hass.localize("ui.tips.key_m_hint"), weight: 1, narrow: false }
+ );
+ }
+
if (narrow) {
tips = tips.filter((tip) => tip.narrow);
}
@@ -310,7 +319,9 @@ class HaConfigDashboard extends SubscribeMixin(LitElement) {
private _showQuickBar(): void {
showQuickBar(this, {
commandMode: true,
- hint: this.hass.localize("ui.dialogs.quick-bar.key_c_hint"),
+ hint: this.hass.enableShortcuts
+ ? this.hass.localize("ui.dialogs.quick-bar.key_c_hint")
+ : undefined,
});
}
diff --git a/src/panels/developer-tools/state/developer-tools-state.ts b/src/panels/developer-tools/state/developer-tools-state.ts
index dc7f04ed6a..046efa310a 100644
--- a/src/panels/developer-tools/state/developer-tools-state.ts
+++ b/src/panels/developer-tools/state/developer-tools-state.ts
@@ -128,9 +128,11 @@ class HaPanelDevState extends LitElement {
allow-custom-entity
item-label-path="entity_id"
>
- ${this.hass.localize("ui.tips.key_e_hint")}
+ ${this.hass.enableShortcuts
+ ? html`${this.hass.localize("ui.tips.key_e_hint")}`
+ : nothing}