From 9f1753a565a617cfddd861818de12eadd2a11258 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 12 Sep 2020 19:36:51 -0400 Subject: [PATCH] Update TextScanner.setEnabled to not reset state if unnecessary (#817) --- ext/mixed/js/text-scanner.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index b2a5508c..26c0687b 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -51,6 +51,7 @@ class TextScanner extends EventDispatcher { this._inputs = []; this._enabled = false; + this._enabledValue = false; this._eventListeners = new EventListenerCollection(); this._primaryTouchIdentifier = null; @@ -84,6 +85,9 @@ class TextScanner extends EventDispatcher { } setEnabled(enabled) { + const value = enabled && this._isPrepared; + if (this._enabledValue === value) { return; } + this._eventListeners.removeAllEventListeners(); this._primaryTouchIdentifier = null; this._preventNextContextMenu = false; @@ -92,8 +96,9 @@ class TextScanner extends EventDispatcher { this._preventScroll = false; this._enabled = enabled; + this._enabledValue = value; - if (this._enabled && this._isPrepared) { + if (value) { this._hookEvents(); } else { this.clearSelection(true);