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
This commit is contained in:
ildar170975 2025-04-14 09:22:33 +03:00 committed by GitHub
parent 43bb9d3401
commit 98ae0295b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 7 deletions

View File

@ -43,6 +43,7 @@ import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
import { haStyle } from "../../../resources/styles"; import { haStyle } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types"; import type { HomeAssistant } from "../../../types";
import { documentationUrl } from "../../../util/documentation-url"; import { documentationUrl } from "../../../util/documentation-url";
import { isMobileClient } from "../../../util/is_mobile";
import "../ha-config-section"; import "../ha-config-section";
import { configSections } from "../ha-panel-config"; import { configSections } from "../ha-panel-config";
import "../repairs/ha-config-repairs"; 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 = { const localizeParam = {
keyboard_shortcut: html`<a href="#" @click=${openFn} keyboard_shortcut: html`<a href="#" @click=${openFn}
>${hass.localize("ui.tips.keyboard_shortcut")}</a >${hass.localize("ui.tips.keyboard_shortcut")}</a

View File

@ -19,6 +19,7 @@ import { storage } from "../../../common/decorators/storage";
import { fireEvent } from "../../../common/dom/fire_event"; import { fireEvent } from "../../../common/dom/fire_event";
import { escapeRegExp } from "../../../common/string/escape_regexp"; import { escapeRegExp } from "../../../common/string/escape_regexp";
import { copyToClipboard } from "../../../common/util/copy-clipboard"; import { copyToClipboard } from "../../../common/util/copy-clipboard";
import { isMobileClient } from "../../../util/is_mobile";
import "../../../components/entity/ha-entity-picker"; import "../../../components/entity/ha-entity-picker";
import "../../../components/ha-alert"; import "../../../components/ha-alert";
import "../../../components/ha-button"; import "../../../components/ha-button";
@ -129,7 +130,7 @@ class HaPanelDevState extends LitElement {
allow-custom-entity allow-custom-entity
item-label-path="entity_id" item-label-path="entity_id"
></ha-entity-picker> ></ha-entity-picker>
${this.hass.enableShortcuts ${this.hass.enableShortcuts && !isMobileClient
? html`<ha-tip .hass=${this.hass} ? html`<ha-tip .hass=${this.hass}
>${this.hass.localize("ui.tips.key_e_tip", { >${this.hass.localize("ui.tips.key_e_tip", {
keyboard_shortcut: html`<a keyboard_shortcut: html`<a

View File

@ -11,6 +11,7 @@ import { isExternal } from "../../data/external";
import type { CoreFrontendUserData } from "../../data/frontend"; import type { CoreFrontendUserData } from "../../data/frontend";
import { getOptimisticFrontendUserDataCollection } from "../../data/frontend"; import { getOptimisticFrontendUserDataCollection } from "../../data/frontend";
import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box"; import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
import { isMobileClient } from "../../util/is_mobile";
import { haStyle } from "../../resources/styles"; import { haStyle } from "../../resources/styles";
import type { HomeAssistant, Route } from "../../types"; import type { HomeAssistant, Route } from "../../types";
import "./ha-advanced-mode-row"; import "./ha-advanced-mode-row";
@ -219,11 +220,15 @@ class HaProfileSectionGeneral extends LitElement {
.narrow=${this.narrow} .narrow=${this.narrow}
.hass=${this.hass} .hass=${this.hass}
></ha-set-suspend-row> ></ha-set-suspend-row>
<ha-enable-shortcuts-row ${!isMobileClient
id="shortcuts" ? html`
.narrow=${this.narrow} <ha-enable-shortcuts-row
.hass=${this.hass} id="shortcuts"
></ha-enable-shortcuts-row> .narrow=${this.narrow}
.hass=${this.hass}
></ha-enable-shortcuts-row>
`
: ""}
</ha-card> </ha-card>
</div> </div>
</hass-tabs-subpage> </hass-tabs-subpage>

3
src/util/is_mobile.ts Normal file
View File

@ -0,0 +1,3 @@
export const isMobileClient = /(?:iphone|android|ipad)/i.test(
navigator.userAgent
);