better scroll/touch handling on mobiles

better scroll/touch handling on mobiles

diff --git a/app/assets/javascripts/discourse/components/emoji-picker.js.es6 b/app/assets/javascripts/discourse/components/emoji-picker.js.es6
index 5ceae8b..d26694a 100644
--- a/app/assets/javascripts/discourse/components/emoji-picker.js.es6
+++ b/app/assets/javascripts/discourse/components/emoji-picker.js.es6
@@ -239,9 +239,8 @@ export default Ember.Component.extend({
   },
 
   _bindEmojiClick($emojisContainer) {
-    // $emojisContainer.off("click", "a");
-    $emojisContainer.on("click", "a", e => {
-      const code = this._codeForEmojiLink($(e.currentTarget));
+    let handler = (event) => {
+      const code = this._codeForEmojiLink($(event.currentTarget));
 
       this._trackEmojiUsage(code);
       this.sendAction("emojiSelected", code);
@@ -251,7 +250,24 @@ export default Ember.Component.extend({
       }
 
       return false;
-    });
+    };
+
+    if(this.site.isMobileDevice) {
+      const self = this;
+
+      $emojisContainer
+        .off("touchstart")
+        .on("touchstart", "a", (touchStartEvent) => {
+          const $this = $(touchStartEvent.currentTarget);
+          $this.on('touchend', (touchEndEvent) => {
+            handler.bind(self)(touchEndEvent);
+            $this.off('touchend');
+          });
+          $this.on('touchmove', () => $this.off('touchend') );
+        });
+    } else {
+      $emojisContainer.on("click", "a", e => handler.bind(this)(e) );
+    }
   },
 
   _bindSectionsScroll() {

GitHub sha: 33c1ce8d

@jjaffeux I don’t know if 3 years is beyond the statute of limitations on bugs but… :sweat_smile: new touchmove listeners are registered on every touchstart and are never cleaned up. :slightly_smiling_face:

1 Like

:ok_hand:I can fix this, Im aware of multiple issues on this screen, this is the first thing ever I did at discourse… I even have a branch where I rewrote most of it, but never got to finish it

Le 14 août 2020 à 15:32, Jarek Radosz notifications@github.com a écrit :

@jjaffeux I don’t know if 3 years is beyond the statute of limitations on bugs but… :sweat_smile: new touchmove listeners are registered on every touchstart and are never cleaned up. :slightly_smiling_face:

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

1 Like