aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuuuube <61125188+Kuuuube@users.noreply.github.com>2024-05-17 15:10:47 -0400
committerjamesmaa <jmaa@berkeley.edu>2024-05-21 10:25:37 -0700
commitdf02b952c129290ae525eb4a3021353a62f16b15 (patch)
tree02fefacaa851e9687601e594012a2e4e0d0c9090
parent7a4b832ccfeb7f13857340cc93b30214d6b53106 (diff)
Disallow scanning while mouse is not moving if input, textarea, or editable elements are active (#958)24.5.14.1
* 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}
*/