about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authortmm576 <tmm576@users.noreply.github.com>2019-01-17 17:27:51 -0500
committerThibaut Girka <thib@sitedethib.com>2019-01-20 11:53:22 +0100
commit9b5810b3e9fd67290c16de810ac5e995925d618e (patch)
tree827163e996017b5d6c32d28b0ecd500211c35e2c /app/javascript
parenta93cb340bd1f7ce6f42943024a4a3431f5671b14 (diff)
Allow event defaults on index for text data transfer (#9840)
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/flavours/glitch/features/ui/index.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/features/ui/index.js b/app/javascript/flavours/glitch/features/ui/index.js
index 7928dfe6c..602d93832 100644
--- a/app/javascript/flavours/glitch/features/ui/index.js
+++ b/app/javascript/flavours/glitch/features/ui/index.js
@@ -166,6 +166,7 @@ export default class UI extends React.Component {
   }
 
   handleDragOver = (e) => {
+    if (this.dataTransferIsText(e.dataTransfer)) return false;
     e.preventDefault();
     e.stopPropagation();
 
@@ -179,6 +180,7 @@ export default class UI extends React.Component {
   }
 
   handleDrop = (e) => {
+    if (this.dataTransferIsText(e.dataTransfer)) return;
     e.preventDefault();
 
     this.setState({ draggingOver: false });
@@ -202,6 +204,10 @@ export default class UI extends React.Component {
     this.setState({ draggingOver: false });
   }
 
+  dataTransferIsText = (dataTransfer) => {
+    return (dataTransfer && Array.from(dataTransfer.types).includes('text/plain') && dataTransfer.items.length === 1);
+  }
+
   closeUploadModal = () => {
     this.setState({ draggingOver: false });
   }