about summary refs log tree commit diff
diff options
context:
space:
mode:
authortmm576 <tmm576@users.noreply.github.com>2019-01-17 17:27:51 -0500
committerEugen Rochko <eugen@zeonfederated.com>2019-01-17 23:27:51 +0100
commit4cd0a1079387f1d54df7230bafdb239412343ea9 (patch)
tree12372e737e72732428b40a87d48f784c22f964dc
parent3c218cd76d0b6ff333ff3d404df5217a4e3cba72 (diff)
Allow event defaults on index for text data transfer (#9840)
-rw-r--r--app/javascript/mastodon/features/ui/index.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/ui/index.js b/app/javascript/mastodon/features/ui/index.js
index a59c0a257..f01c2bf24 100644
--- a/app/javascript/mastodon/features/ui/index.js
+++ b/app/javascript/mastodon/features/ui/index.js
@@ -243,6 +243,7 @@ class UI extends React.PureComponent {
   }
 
   handleDragOver = (e) => {
+    if (this.dataTransferIsText(e.dataTransfer)) return false;
     e.preventDefault();
     e.stopPropagation();
 
@@ -256,6 +257,7 @@ class UI extends React.PureComponent {
   }
 
   handleDrop = (e) => {
+    if (this.dataTransferIsText(e.dataTransfer)) return;
     e.preventDefault();
 
     this.setState({ draggingOver: false });
@@ -279,6 +281,10 @@ class UI extends React.PureComponent {
     this.setState({ draggingOver: false });
   }
 
+  dataTransferIsText = (dataTransfer) => {
+    return (dataTransfer && Array.from(dataTransfer.types).includes('text/plain') && dataTransfer.items.length === 1);
+  }
+
   closeUploadModal = () => {
     this.setState({ draggingOver: false });
   }