From 684e43a35217d51aeb12fcc6be09bd2c60d47a7f Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Mon, 18 Sep 2023 22:32:21 +0200 Subject: [PATCH] prevent autofocus of dialog elements on mobile --- public/index.html | 2 +- public/scripts/ui.js | 6 +++--- public_included_ws_fallback/index.html | 2 +- public_included_ws_fallback/scripts/ui.js | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/public/index.html b/public/index.html index e585743..ced4bff 100644 --- a/public/index.html +++ b/public/index.html @@ -337,7 +337,7 @@
- +
diff --git a/public/scripts/ui.js b/public/scripts/ui.js index d76be78..e253f36 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -1,8 +1,8 @@ const $ = query => document.getElementById(query); const $$ = query => document.body.querySelector(query); -window.isProductionEnvironment = !window.location.host.startsWith('localhost'); window.iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; window.android = /android/i.test(navigator.userAgent); +window.isMobile = window.iOS || window.android; window.pasteMode = {}; window.pasteMode.activated = false; @@ -600,7 +600,7 @@ class Dialog { show() { this.$el.setAttribute('show', 1); - if (this.$autoFocus) this.$autoFocus.focus(); + if (!window.isMobile && this.$autoFocus) this.$autoFocus.focus(); } isShown() { @@ -609,7 +609,7 @@ class Dialog { hide() { this.$el.removeAttribute('show'); - if (this.$autoFocus) { + if (!window.isMobile && this.$autoFocus) { document.activeElement.blur(); window.blur(); } diff --git a/public_included_ws_fallback/index.html b/public_included_ws_fallback/index.html index 4cd5fea..e52a0d4 100644 --- a/public_included_ws_fallback/index.html +++ b/public_included_ws_fallback/index.html @@ -342,7 +342,7 @@
- +
diff --git a/public_included_ws_fallback/scripts/ui.js b/public_included_ws_fallback/scripts/ui.js index ac0d0fa..2304644 100644 --- a/public_included_ws_fallback/scripts/ui.js +++ b/public_included_ws_fallback/scripts/ui.js @@ -1,8 +1,8 @@ const $ = query => document.getElementById(query); const $$ = query => document.body.querySelector(query); -window.isProductionEnvironment = !window.location.host.startsWith('localhost'); window.iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; window.android = /android/i.test(navigator.userAgent); +window.isMobile = window.iOS || window.android; window.pasteMode = {}; window.pasteMode.activated = false; @@ -602,7 +602,7 @@ class Dialog { show() { this.$el.setAttribute('show', 1); - if (this.$autoFocus) this.$autoFocus.focus(); + if (!window.isMobile && this.$autoFocus) this.$autoFocus.focus(); } isShown() { @@ -611,7 +611,7 @@ class Dialog { hide() { this.$el.removeAttribute('show'); - if (this.$autoFocus) { + if (!window.isMobile && this.$autoFocus) { document.activeElement.blur(); window.blur(); }