TagSpaces is an offline, open source, document manager with tagging support
fix Select file before start draging (#1748)
Stanimir7006ef97af81
diff --git a/app/components/FileSourceDnd.tsx b/app/components/FileSourceDnd.tsxindex 3ed4069c9..c18d9e050 100644--- a/app/components/FileSourceDnd.tsx+++ b/app/components/FileSourceDnd.tsx@@ -30,10 +30,19 @@ interface Props {const boxSource = {beginDrag(props) {// console.log('beginDrag', props);- return {- path: props.children.props.entryPath,- selectedEntries: props.children.props.selectedEntries- };+ const entryPath = props.children.props.entryPath;+ const selectedEntries = props.children.props.selectedEntries;+ if (!selectedEntries.some(entry => entry.path === entryPath)) {+ return {+ path: entryPath,+ selectedEntries: [{ path: entryPath }]+ };+ } else {+ return {+ path: entryPath,+ selectedEntries: selectedEntries+ };+ }}/* endDrag(props, monitor) {diff --git a/app/perspectives/grid-perspective/components/CellContent.tsx b/app/perspectives/grid-perspective/components/CellContent.tsxindex 4eefe7bef..aa1e50e4f 100644--- a/app/perspectives/grid-perspective/components/CellContent.tsx+++ b/app/perspectives/grid-perspective/components/CellContent.tsx@@ -499,6 +499,10 @@ function CellContent(props: Props) {? handleGridCellDblClick(event, fsEntry): handleGridCellClick(event, fsEntry);}}+ onDrag={event => {+ // event.stopPropagation();+ handleGridCellClick(event, fsEntry);+ }}>{gridCell}</Paper>diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsxindex 93a398aa5..bf1a35adb 100644--- a/app/perspectives/grid-perspective/components/MainContainer.tsx+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx@@ -438,6 +438,17 @@ function GridPerspective(props: Props) {}setSelectedEntries(entriesToSelect);+ } else if (event.type === 'drag') {+ if (+ selectedEntries &&+ selectedEntries.some(entry => entry.path === fsEntry.path)+ ) {+ } else {+ const currentSelectedEntry = directoryContent.find(+ entry => entry.path === fsEntry.path+ );+ setSelectedEntries([currentSelectedEntry]);+ }} else if (selectHelperKey) {if (selectedEntries &&@@ -678,7 +689,7 @@ function GridPerspective(props: Props) {const arrSelected = mItem.selectedEntries.map(entry => entry.path)// remove target folder selection- .filter(epath => epath !== mItem.path);+ .filter(epath => epath !== item.path);if (arrSelected.length > 0) {arrPath = arrSelected;} else {diff --git a/app/perspectives/list/components/MainContainer.tsx b/app/perspectives/list/components/MainContainer.tsxindex 34739285a..c928bc498 100644--- a/app/perspectives/list/components/MainContainer.tsx+++ b/app/perspectives/list/components/MainContainer.tsx@@ -440,6 +440,17 @@ function GridPerspective(props: Props) {}setSelectedEntries(entriesToSelect);+ } else if (event.type === 'drag') {+ if (+ selectedEntries &&+ selectedEntries.some(entry => entry.path === fsEntry.path)+ ) {+ } else {+ const currentSelectedEntry = directoryContent.find(+ entry => entry.path === fsEntry.path+ );+ setSelectedEntries([currentSelectedEntry]);+ }} else if (selectHelperKey) {if (selectedEntries &&