aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuuuube <61125188+Kuuuube@users.noreply.github.com>2024-05-17 15:10:47 -0400
committerGitHub <noreply@github.com>2024-05-17 19:10:47 +0000
commite19204b1ec26a1add25ae47903184dea8e705a33 (patch)
treeeb85ccc1a42697497c0c8ddfd679e8d8ba5d23eb
parent576a47028cfb51f3d28c84c24257843c6d7f042e (diff)
Disallow scanning while mouse is not moving if input, textarea, or editable elements are active (#958)
* Disallow scanning while mouse is not moving if input, textarea, or editable elements are active * Move to _inputtingText method
-rw-r--r--ext/js/language/text-scanner.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js
index 13db91d5..7c1b5b33 100644
--- a/ext/js/language/text-scanner.js
+++ b/ext/js/language/text-scanner.js
@@ -562,6 +562,7 @@ export class TextScanner extends EventDispatcher {
*/
_onKeyDown(e) {
if (this._lastMouseMove !== null && (e.ctrlKey || e.shiftKey || e.altKey || e.metaKey)) {
+ if (this._inputtingText()) { return; }
const syntheticMouseEvent = new MouseEvent(this._lastMouseMove.type, {
screenX: this._lastMouseMove.screenX,
screenY: this._lastMouseMove.screenY,
@@ -580,6 +581,18 @@ export class TextScanner extends EventDispatcher {
}
/**
+ * @returns {boolean}
+ */
+ _inputtingText() {
+ const activeElement = document.activeElement;
+ if (activeElement && activeElement instanceof HTMLElement) {
+ if (activeElement.nodeName === 'INPUT' || activeElement.nodeName === 'TEXTAREA') { return true; }
+ if (activeElement.isContentEditable) { return true; }
+ }
+ return false;
+ }
+
+ /**
* @param {MouseEvent} e
* @returns {boolean|void}
*/