From d58f38056574a60ba4eb77ce898792293242fbb6 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Wed, 3 Jan 2024 16:53:09 +0100 Subject: [PATCH] Prevent executing _onCopy() when text is selected on receive text dialog --- public/scripts/ui.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/scripts/ui.js b/public/scripts/ui.js index ffef7ee..1917eb8 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -1978,12 +1978,15 @@ class ReceiveTextDialog extends Dialog { this._receiveTextQueue = []; } + selectionEmpty() { + return !window.getSelection().toString() + } + async _onKeyDown(e) { if (!this.isShown()) return - if (e.code === "KeyC" && (e.ctrlKey || e.metaKey)) { + if (e.code === "KeyC" && (e.ctrlKey || e.metaKey) && this.selectionEmpty()) { await this._onCopy() - this.hide(); } else if (e.code === "Escape") { this.hide();