From 79a8b813afd8860446c4e4478243e0856f044c39 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Wed, 26 Jan 2022 21:28:58 +0000 Subject: [PATCH 1/2] Turn off Polymer setting to cancel synthetic click events for all UI entrypoints --- src/entrypoints/app.ts | 6 +++++- src/entrypoints/authorize.ts | 3 +++ src/entrypoints/custom-panel.ts | 5 ++++- src/entrypoints/onboarding.ts | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/entrypoints/app.ts b/src/entrypoints/app.ts index 39c5f4c493f9..7468a81a60ba 100644 --- a/src/entrypoints/app.ts +++ b/src/entrypoints/app.ts @@ -1,9 +1,13 @@ -import { setPassiveTouchGestures } from "@polymer/polymer/lib/utils/settings"; +import { + setPassiveTouchGestures, + setCancelSyntheticClickEvents, +} from "@polymer/polymer/lib/utils/settings"; import "../layouts/home-assistant"; import "../resources/ha-style"; import "../resources/roboto"; import "../util/legacy-support"; setPassiveTouchGestures(true); +setCancelSyntheticClickEvents(false); (window as any).frontendVersion = __VERSION__; diff --git a/src/entrypoints/authorize.ts b/src/entrypoints/authorize.ts index 36954a3fcf9f..47ba124a9180 100644 --- a/src/entrypoints/authorize.ts +++ b/src/entrypoints/authorize.ts @@ -1,11 +1,14 @@ // Compat needs to be first import import "../resources/compatibility"; +import { setCancelSyntheticClickEvents } from "@polymer/polymer/lib/utils/settings"; import "../auth/ha-authorize"; import "../resources/ha-style"; import "../resources/roboto"; import "../resources/safari-14-attachshadow-patch"; import "../resources/array.flat.polyfill"; +setCancelSyntheticClickEvents(false); + /* polyfill for paper-dropdown */ setTimeout( () => import("web-animations-js/web-animations-next-lite.min"), diff --git a/src/entrypoints/custom-panel.ts b/src/entrypoints/custom-panel.ts index e2da175ea8dc..2e09f9931b49 100644 --- a/src/entrypoints/custom-panel.ts +++ b/src/entrypoints/custom-panel.ts @@ -1,5 +1,6 @@ // Compat needs to be first import import "../resources/compatibility"; +import { setCancelSyntheticClickEvents } from "@polymer/polymer/lib/utils/settings"; import "../resources/safari-14-attachshadow-patch"; import { PolymerElement } from "@polymer/polymer"; @@ -15,6 +16,8 @@ import { createCustomPanelElement } from "../util/custom-panel/create-custom-pan import { loadCustomPanel } from "../util/custom-panel/load-custom-panel"; import { setCustomPanelProperties } from "../util/custom-panel/set-custom-panel-properties"; +setCancelSyntheticClickEvents(false); + declare global { interface Window { loadES5Adapter: () => Promise; @@ -47,7 +50,7 @@ function initialize( ) { const style = document.createElement("style"); - style.innerHTML = `body { margin:0; } + style.innerHTML = `body { margin:0; } @media (prefers-color-scheme: dark) { body { background-color: #111111; diff --git a/src/entrypoints/onboarding.ts b/src/entrypoints/onboarding.ts index 44a67890abc3..78696169ca5a 100644 --- a/src/entrypoints/onboarding.ts +++ b/src/entrypoints/onboarding.ts @@ -1,11 +1,14 @@ // Compat needs to be first import import "../resources/compatibility"; +import { setCancelSyntheticClickEvents } from "@polymer/polymer/lib/utils/settings"; import "../onboarding/ha-onboarding"; import "../resources/ha-style"; import "../resources/roboto"; import "../resources/safari-14-attachshadow-patch"; import "../resources/array.flat.polyfill"; +setCancelSyntheticClickEvents(false); + declare global { interface Window { stepsPromise: Promise; From cbc96938e59a0c184f376d98f8acd8298bbd0b1c Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Wed, 26 Jan 2022 21:46:24 +0000 Subject: [PATCH 2/2] Add comment to warn that compatibility.ts is not used in latest builds --- src/resources/compatibility.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/resources/compatibility.ts b/src/resources/compatibility.ts index 03a0b23feca9..07f80f0ff8cf 100644 --- a/src/resources/compatibility.ts +++ b/src/resources/compatibility.ts @@ -1,3 +1,4 @@ +// Caution before editing - For latest builds, this module is replaced with emptiness and thus not imported (see build-scripts/bundle.js) import "core-js"; import "regenerator-runtime/runtime"; import "lit/polyfill-support";