Skip to content

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

fixing issue with wrong selection on perspective commands

Ilian Sapundshiev9b7da7b0e6ae
diff --git a/app/components/FolderContainer.js b/app/components/FolderContainer.js
index 6dfe4c1db..1b29534d7 100644
--- a/app/components/FolderContainer.js
+++ b/app/components/FolderContainer.js
@@ -178,7 +178,7 @@ class FolderContainer extends React.Component<Props, State> {
directoryContextMenuAnchorEl: null,
perspectiveChooserMenuOpened: false,
perspectiveChooserMenuAnchorEl: null,
- perspectiveCommand: {}
+ perspectiveCommand: null
};
static getDerivedStateFromProps(nextProps, prevState) {
@@ -232,7 +232,7 @@ class FolderContainer extends React.Component<Props, State> {
perspectiveCommand: { key: 'TOGGLE_SELECT_ALL' }
},
() => {
- this.setState({ perspectiveCommand: {} });
+ this.setState({ perspectiveCommand: null });
}
);
},
@@ -242,7 +242,7 @@ class FolderContainer extends React.Component<Props, State> {
perspectiveCommand: { key: 'DELETE_SELECTED_ENTRIES' }
},
() => {
- this.setState({ perspectiveCommand: {} });
+ this.setState({ perspectiveCommand: null });
}
);
},
@@ -252,7 +252,7 @@ class FolderContainer extends React.Component<Props, State> {
perspectiveCommand: { key: 'ADD_REMOVE_TAGS' }
},
() => {
- this.setState({ perspectiveCommand: {} });
+ this.setState({ perspectiveCommand: null });
}
);
},
@@ -262,7 +262,7 @@ class FolderContainer extends React.Component<Props, State> {
perspectiveCommand: { key: 'RENAME_ENTRY' }
},
() => {
- this.setState({ perspectiveCommand: {} });
+ this.setState({ perspectiveCommand: null });
}
);
},
diff --git a/app/perspectives/grid-perspective/src/index.js b/app/perspectives/grid-perspective/src/index.js
index a4ac77331..9ecad3187 100644
--- a/app/perspectives/grid-perspective/src/index.js
+++ b/app/perspectives/grid-perspective/src/index.js
@@ -181,38 +181,20 @@ class GridPerspective extends React.Component<Props, State> {
}
componentWillReceiveProps = (nextProps: Props) => {
- const cmd = nextProps.perspectiveCommand;
- const { directoryContent, lastSelectedEntryPath } = nextProps;
+ const { directoryContent, lastSelectedEntryPath, perspectiveCommand } = nextProps;
- if (lastSelectedEntryPath !== null) {
- this.setState(
- {
- selectedEntries: directoryContent.filter(
- fsEntry => fsEntry.path === lastSelectedEntryPath
- )
- },
- () => {
- this.computeFileOperationsEnabled();
- // this.makeFirstSelectedEntryVisible(); // disable due to wrong scrolling
- }
- );
- }
-
- if (cmd && cmd.key) {
- if (cmd.key === 'TOGGLE_SELECT_ALL') {
+ if (perspectiveCommand && perspectiveCommand.key) {
+ this.props.setLastSelectedEntry(null);
+ if (perspectiveCommand.key === 'TOGGLE_SELECT_ALL') {
this.toggleSelectAllFiles();
- }
-
- if (
- cmd.key === 'ADD_REMOVE_TAGS' &&
+ } else if (
+ perspectiveCommand.key === 'ADD_REMOVE_TAGS' &&
this.state.selectedEntries &&
this.state.selectedEntries.length > 0
) {
this.openAddRemoveTagsDialog();
- }
-
- if (
- cmd.key === 'RENAME_ENTRY' &&
+ } else if (
+ perspectiveCommand.key === 'RENAME_ENTRY' &&
this.state.selectedEntries &&
this.state.selectedEntries.length === 1
) {
@@ -221,13 +203,25 @@ class GridPerspective extends React.Component<Props, State> {
this.openFileRenameDialog();
});
}
- }
-
- if (cmd.key === 'DELETE_SELECTED_ENTRIES' && this.state.fileOperationsEnabled) {
+ } else if (perspectiveCommand.key === 'DELETE_SELECTED_ENTRIES' && this.state.fileOperationsEnabled) {
this.openDeleteFileDialog();
}
}
+ if (lastSelectedEntryPath !== null) {
+ this.setState(
+ {
+ selectedEntries: directoryContent.filter(
+ fsEntry => fsEntry.path === lastSelectedEntryPath
+ )
+ },
+ () => {
+ this.computeFileOperationsEnabled();
+ // this.makeFirstSelectedEntryVisible(); // disable due to wrong scrolling
+ }
+ );
+ }
+
// Directory changed
if (
nextProps.currentDirectoryPath !== this.props.currentDirectoryPath &&