From a34121e3430319e8e83b4b33d5f4a4078768395e Mon Sep 17 00:00:00 2001 From: Nicolas Ramz Date: Mon, 18 Nov 2019 19:35:37 +0100 Subject: [PATCH] FIXED: parent shortcut didn't work if folder was empty, fixes #89 (#92) --- src/components/FileTable.tsx | 12 ++---------- src/components/Toolbar.tsx | 2 +- src/state/fileState.ts | 4 ++-- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/components/FileTable.tsx b/src/components/FileTable.tsx index 0f3938b7..598cb48a 100644 --- a/src/components/FileTable.tsx +++ b/src/components/FileTable.tsx @@ -731,16 +731,8 @@ export class FileTableClass extends React.Component { break; case KEYS.Backspace: - // TODO: this is used in Log as well, share the code ! - const { nodes } = this.state; - - if (!this.editingElement && nodes.length) { - const node = nodes[0]; - const file = node.nodeData as File; - - if (!fileCache.isRoot(file.dir)) { - this.cache.openParentDirectory(); - } + if (!this.editingElement && !this.cache.isRoot()) { + this.cache.openParentDirectory(); } break; } diff --git a/src/components/Toolbar.tsx b/src/components/Toolbar.tsx index 6fa776b7..7282669b 100644 --- a/src/components/Toolbar.tsx +++ b/src/components/Toolbar.tsx @@ -411,7 +411,7 @@ export class ToolbarClass extends React.Component { const intent = status === -1 ? 'danger' : 'none'; const count = selected.length; - const isRoot = fileCache.isRoot(fileCache.path); + const isRoot = fileCache.isRoot(); return ( diff --git a/src/state/fileState.ts b/src/state/fileState.ts index e569e524..895d4c3a 100644 --- a/src/state/fileState.ts +++ b/src/state/fileState.ts @@ -562,7 +562,7 @@ export class FileState { }); } - isRoot(path: string): boolean { - return this.api ? this.api.isRoot(path) : false; + isRoot(path = this.path): boolean { + return this.api ? path && this.api.isRoot(path) : false; } }