]> cat aescling's git repositories - mastodon.git/commitdiff
Fix toots opening in dynamic column when trying to interact with them
authorThibaut Girka <thib@sitedethib.com>
Tue, 5 Mar 2019 22:17:09 +0000 (23:17 +0100)
committerThibG <thib@sitedethib.com>
Tue, 5 Mar 2019 23:20:43 +0000 (00:20 +0100)
This fixes inline preview cards and polls, preventing them from opening
the toot in detailed view when clicking on an interactive element.

app/javascript/flavours/glitch/components/status_content.js

index c60d63f9a125f26eff2a6bef9e888ac83480c12a..98a34ebaf613542007059856b581171ac4653682 100644 (file)
@@ -100,8 +100,12 @@ export default class StatusContent extends React.PureComponent {
     const [ startX, startY ] = this.startXY;
     const [ deltaX, deltaY ] = [Math.abs(e.clientX - startX), Math.abs(e.clientY - startY)];
 
-    if (e.target.localName === 'button' || e.target.localName == 'video' || e.target.localName === 'a' || (e.target.parentNode && (e.target.parentNode.localName === 'button' || e.target.parentNode.localName === 'a'))) {
-      return;
+    let element = e.target;
+    while (element) {
+      if (element.localName === 'button' || element.localName === 'video' || element.localName === 'a' || element.localName === 'label') {
+        return;
+      }
+      element = element.parentNode;
     }
 
     if (deltaX + deltaY < 5 && e.button === 0 && parseClick) {