From dacffdd62e545fa57797c91bb735630eb494e51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 9 Apr 2021 07:57:25 +0200 Subject: [PATCH] Add some comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/structures/RoomView.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 9cebecd944..7168b7d139 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -1137,8 +1137,13 @@ export default class RoomView extends React.Component { ev.stopPropagation(); ev.preventDefault(); + // We always increment the counter no matter the types, because dragging is + // still happening. If we didn't, the drag counter would get out of sync. this.setState({dragCounter: this.state.dragCounter + 1}); + // See: + // https://docs.w3cub.com/dom/datatransfer/types + // https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file if (ev.dataTransfer.types.includes("Files") || ev.dataTransfer.types.includes("application/x-moz-file")) { this.setState({draggingFile: true}); } @@ -1165,6 +1170,9 @@ export default class RoomView extends React.Component { ev.dataTransfer.dropEffect = 'none'; + // See: + // https://docs.w3cub.com/dom/datatransfer/types + // https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file if (ev.dataTransfer.types.includes("Files") || ev.dataTransfer.types.includes("application/x-moz-file")) { ev.dataTransfer.dropEffect = 'copy'; }