diff --git a/public/scripts/ui.js b/public/scripts/ui.js index cb28677..b494f58 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -1296,13 +1296,13 @@ class SendTextDialog extends Dialog { } async _onKeyDown(e) { - if (this.isShown()) { - if (e.code === "Escape") { - this.hide(); - } else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) { - if (this._textInputEmpty()) return; - this._send(); - } + if (!this.isShown()) return; + + if (e.code === "Escape") { + this.hide(); + } else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) { + if (this._textInputEmpty()) return; + this._send(); } } @@ -1420,7 +1420,8 @@ class ReceiveTextDialog extends Dialog { } async _onCopy() { - await navigator.clipboard.writeText(this.$text.innerText); + const sanitizedText = this.$text.innerText.replace(/\u00A0/gm, ' '); + await navigator.clipboard.writeText(sanitizedText); Events.fire('notify-user', 'Copied to clipboard'); this.hide(); } diff --git a/public_included_ws_fallback/scripts/ui.js b/public_included_ws_fallback/scripts/ui.js index 52055ad..d355468 100644 --- a/public_included_ws_fallback/scripts/ui.js +++ b/public_included_ws_fallback/scripts/ui.js @@ -1297,13 +1297,13 @@ class SendTextDialog extends Dialog { } async _onKeyDown(e) { - if (this.isShown()) { - if (e.code === "Escape") { - this.hide(); - } else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) { - if (this._textInputEmpty()) return; - this._send(); - } + if (!this.isShown()) return; + + if (e.code === "Escape") { + this.hide(); + } else if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) { + if (this._textInputEmpty()) return; + this._send(); } } @@ -1421,7 +1421,8 @@ class ReceiveTextDialog extends Dialog { } async _onCopy() { - await navigator.clipboard.writeText(this.$text.innerText); + const sanitizedText = this.$text.innerText.replace(/\u00A0/gm, ' '); + await navigator.clipboard.writeText(sanitizedText); Events.fire('notify-user', 'Copied to clipboard'); this.hide(); }