Skip to content

TagSpaces is an offline, open source, document manager with tagging support

dnd fixes - mouse cursor offset && selected 0 entries

stanimir706e7aac3fea
diff --git a/app/components/CustomDragLayer.tsx b/app/components/CustomDragLayer.tsx
index 680162fad..31e72a98d 100644
--- a/app/components/CustomDragLayer.tsx
+++ b/app/components/CustomDragLayer.tsx
@@ -15,7 +15,8 @@ const layerStyles: React.CSSProperties = {
function getItemStyles(
initialOffset: XYCoord | null,
- currentOffset: XYCoord | null
+ currentOffset: XYCoord | null,
+ clientOffset: XYCoord | null
) {
if (!initialOffset || !currentOffset) {
return {
@@ -23,7 +24,7 @@ function getItemStyles(
};
}
- const { x, y } = currentOffset;
+ const { x, y } = clientOffset; // currentOffset;
const transform = `translate(${x}px, ${y}px)`;
return {
@@ -40,12 +41,14 @@ export const CustomDragLayer: React.FC<CustomDragLayerProps> = props => {
isDragging,
item,
initialOffset,
- currentOffset
+ currentOffset,
+ clientOffset
} = useDragLayer(monitor => ({
item: monitor.getItem(),
itemType: monitor.getItemType(),
initialOffset: monitor.getInitialSourceClientOffset(),
currentOffset: monitor.getSourceClientOffset(),
+ clientOffset: monitor.getClientOffset(),
isDragging: monitor.isDragging()
}));
@@ -66,7 +69,7 @@ export const CustomDragLayer: React.FC<CustomDragLayerProps> = props => {
}
return (
<div style={layerStyles}>
- <div style={getItemStyles(initialOffset, currentOffset)}>
+ <div style={getItemStyles(initialOffset, currentOffset, clientOffset)}>
{renderItem()}
</div>
</div>
diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsx
index fc821de76..6c5900bde 100644
--- a/app/perspectives/grid-perspective/components/MainContainer.tsx
+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx
@@ -588,12 +588,16 @@ class GridPerspective extends React.Component<Props, State> {
selectedEntries.some(entry => entry.path === fsEntry.path)
) {
selected = true;
- }
+ } /* else {
+ selectedEntries.push(fsEntry);
+ } */
const cellContent: any = (
<TagDropContainer
- entryPath={fsEntry.path}
- selectedEntries={selectedEntries}
+ entryPath={fsEntry.path} // TODO remove entryPath it is already included in selectedEntries
+ selectedEntries={
+ selectedEntries.length > 0 ? selectedEntries : [fsEntry]
+ }
>
<CellContent
selected={selected}