From b08cc31940da4f9ad02cdad73393b36e7146e5fb Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Wed, 28 Oct 2020 17:21:18 +0800 Subject: [PATCH] feature: consistant behavior of hit enter on search results --- src/driver/core/FileExplorer.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/driver/core/FileExplorer.ts b/src/driver/core/FileExplorer.ts index ad9e6ec..9f8f1c0 100644 --- a/src/driver/core/FileExplorer.ts +++ b/src/driver/core/FileExplorer.ts @@ -144,17 +144,16 @@ export const handleKeyDown: BoundMethodCreator<[React.KeyboardEvent]> = dispatch break case 'Enter': // expand node or redirect to file page - if (focusedNode.type === 'tree') { - if (searched) { - dispatch.call(goTo, focusedNode.path.split('/')) - } else { - dispatch.call(setExpand, focusedNode, true) + if (searched) { + dispatch.call(goTo, focusedNode.path.split('/')) + } else { + if (focusedNode.type === 'tree') { + dispatch.call(toggleNodeExpansion, focusedNode, { recursive: event.altKey }) + } else if (focusedNode.type === 'blob') { + if (focusedNode.url) loadWithPJAX(focusedNode.url) + } else if (focusedNode.type === 'commit') { + window.open(focusedNode.url) } - } else if (focusedNode.type === 'blob') { - if (searched) dispatch.call(goTo, focusedNode.path.split('/')) - else if (focusedNode.url) loadWithPJAX(focusedNode.url) - } else if (focusedNode.type === 'commit') { - window.open(focusedNode.url) } break default: