From 98ae0295b482cc6c65dee7ff449bc416298221b0 Mon Sep 17 00:00:00 2001
From: ildar170975 <71872483+ildar170975@users.noreply.github.com>
Date: Mon, 14 Apr 2025 09:22:33 +0300
Subject: [PATCH] Do not show tips for shortcuts on a client with a touch
screen (#25020)
* check isTouch
* check isTouch
* check isTouch
* restored lost line
* isTouch -> isMobileClient
* isTouch -> isMobileClient
* isTouch -> isMobileClient
* Create is_mobile.ts
---
.../config/dashboard/ha-config-dashboard.ts | 3 ++-
.../state/developer-tools-state.ts | 3 ++-
src/panels/profile/ha-profile-section-general.ts | 15 ++++++++++-----
src/util/is_mobile.ts | 3 +++
4 files changed, 17 insertions(+), 7 deletions(-)
create mode 100644 src/util/is_mobile.ts
diff --git a/src/panels/config/dashboard/ha-config-dashboard.ts b/src/panels/config/dashboard/ha-config-dashboard.ts
index f1f5280c6d..ab6aeadc4b 100644
--- a/src/panels/config/dashboard/ha-config-dashboard.ts
+++ b/src/panels/config/dashboard/ha-config-dashboard.ts
@@ -43,6 +43,7 @@ import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
import { haStyle } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url";
+import { isMobileClient } from "../../../util/is_mobile";
import "../ha-config-section";
import { configSections } from "../ha-panel-config";
import "../repairs/ha-config-repairs";
@@ -105,7 +106,7 @@ const randomTip = (openFn: any, hass: HomeAssistant, narrow: boolean) => {
},
];
- if (hass?.enableShortcuts) {
+ if (hass?.enableShortcuts && !isMobileClient) {
const localizeParam = {
keyboard_shortcut: html`${hass.localize("ui.tips.keyboard_shortcut")}
- ${this.hass.enableShortcuts
+ ${this.hass.enableShortcuts && !isMobileClient
? html`${this.hass.localize("ui.tips.key_e_tip", {
keyboard_shortcut: html`
-
+ ${!isMobileClient
+ ? html`
+
+ `
+ : ""}
diff --git a/src/util/is_mobile.ts b/src/util/is_mobile.ts
new file mode 100644
index 0000000000..5676274919
--- /dev/null
+++ b/src/util/is_mobile.ts
@@ -0,0 +1,3 @@
+export const isMobileClient = /(?:iphone|android|ipad)/i.test(
+ navigator.userAgent
+);