Prevent the tooltip being selectable while the user changes the selection
authorAlexander Ebert <ebert@woltlab.com>
Sun, 6 Dec 2020 20:10:59 +0000 (21:10 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 6 Dec 2020 20:10:59 +0000 (21:10 +0100)
wcfsetup/install/files/js/WCF.Message.js

index e6c93a06ba3abc7eb93cb974a3bed4466d30c859..6450ff7e83f86b4f005f7ea8acb8e9858cc7fd5c 100644 (file)
@@ -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});
                },
                
                /**