From cd669b13d9bc407ac6cbed79282bf620f77d3854 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Wed, 11 Oct 2023 18:17:12 +0200 Subject: [PATCH] Fix display name not being editable on some older iOS devices (#163) --- public/scripts/ui.js | 3 +-- public/styles.css | 7 +++++++ public_included_ws_fallback/scripts/ui.js | 3 +-- public_included_ws_fallback/styles.css | 7 +++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/public/scripts/ui.js b/public/scripts/ui.js index 3840648..20767e2 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -1767,7 +1767,6 @@ class SendTextDialog extends Dialog { const range = document.createRange(); const sel = window.getSelection(); - this.$text.focus(); range.selectNodeContents(this.$text); sel.removeAllRanges(); sel.addRange(range); @@ -1783,7 +1782,7 @@ class SendTextDialog extends Dialog { to: this.correspondingPeerId, text: this.$text.innerText }); - this.$text.value = ""; + this.$text.innerText = ""; this.hide(); } } diff --git a/public/styles.css b/public/styles.css index fe0674c..589a5de 100644 --- a/public/styles.css +++ b/public/styles.css @@ -1589,3 +1589,10 @@ x-dialog x-paper { color: black; background: var(--primary-color); } + +/* make elements with attribute contenteditable editable on older iOS devices. +See note here: https://developer.mozilla.org/en-US/docs/Web/CSS/user-select */ +[contenteditable] { + -webkit-user-select: text; + user-select: text; +} diff --git a/public_included_ws_fallback/scripts/ui.js b/public_included_ws_fallback/scripts/ui.js index 6d3c084..a6d44fb 100644 --- a/public_included_ws_fallback/scripts/ui.js +++ b/public_included_ws_fallback/scripts/ui.js @@ -1769,7 +1769,6 @@ class SendTextDialog extends Dialog { const range = document.createRange(); const sel = window.getSelection(); - this.$text.focus(); range.selectNodeContents(this.$text); sel.removeAllRanges(); sel.addRange(range); @@ -1785,7 +1784,7 @@ class SendTextDialog extends Dialog { to: this.correspondingPeerId, text: this.$text.innerText }); - this.$text.value = ""; + this.$text.innerText = ""; this.hide(); } } diff --git a/public_included_ws_fallback/styles.css b/public_included_ws_fallback/styles.css index 1b8024e..b90a5bd 100644 --- a/public_included_ws_fallback/styles.css +++ b/public_included_ws_fallback/styles.css @@ -1619,3 +1619,10 @@ x-dialog x-paper { color: black; background: var(--primary-color); } + +/* make elements with attribute contenteditable editable on older iOS devices. +See note here: https://developer.mozilla.org/en-US/docs/Web/CSS/user-select */ +[contenteditable] { + -webkit-user-select: text; + user-select: text; +}