From 98b26407301f59638f28d1e01259cf8f8a59f801 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 6 Dec 2020 21:10:59 +0100 Subject: [PATCH] Prevent the tooltip being selectable while the user changes the selection --- wcfsetup/install/files/js/WCF.Message.js | 29 ++++++++++-------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index e6c93a06ba..6450ff7e83 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -1155,24 +1155,19 @@ if (COMPILER_TARGET_DEFAULT) { WCF.DOMNodeInsertedHandler.addCallback('WCF.Message.Quote.Handler' + objectType.hashCode(), $.proxy(this._initContainers, this)); // Prevent the tooltip from being selectable while the touch pointer is being moved. - var timer = null; - document.addEventListener('selectionchange', (function() { - if (!this._copyQuote[0].classList.contains('active')) { - return; - } - - this._copyQuote[0].classList.add('touchForceInaccessible'); - - if (timer !== null) { - window.clearTimeout(timer); + const tooltip = this._copyQuote[0]; + document.addEventListener("touchstart", function (event) { + if (tooltip.classList.contains("active")) { + const target = event.target; + if (target !== tooltip && !tooltip.contains(target)) { + tooltip.classList.add("touchForceInaccessible"); + + document.addEventListener("touchend", function () { + tooltip.classList.remove("touchForceInaccessible"); + }, {once: true}); + } } - - timer = window.setTimeout((function() { - this._copyQuote[0].classList.remove('touchForceInaccessible'); - - timer = null; - }).bind(this), 50); - }).bind(this)); + }, {passive: true}); }, /** -- 2.20.1