mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
feat: keyboard shortcut for reveal item
This commit is contained in:
parent
a09bba0a36
commit
72356a2ebf
1 changed files with 8 additions and 4 deletions
|
|
@ -94,7 +94,6 @@ const setUpTree: MethodCreator<Props, ConnectorState> = dispatch => () =>
|
|||
tasksAfterRender.push(DOMHelper.focusSearchInput)
|
||||
dispatch.call(setStateText, '')
|
||||
dispatch.call(goTo, URLHelper.getCurrentPath(metaData.branchName))
|
||||
dispatch.call(updateVisibleNodes)
|
||||
})
|
||||
|
||||
const execAfterRender: MethodCreator<Props, ConnectorState> = dispatch => () => {
|
||||
|
|
@ -118,7 +117,7 @@ const handleKeyDown: MethodCreator<
|
|||
ConnectorState,
|
||||
[React.KeyboardEvent]
|
||||
> = dispatch => event =>
|
||||
dispatch.get(({ visibleNodes: { nodes, focusedNode, expandedNodes, depths } }) => {
|
||||
dispatch.get(({ searched, visibleNodes: { nodes, focusedNode, expandedNodes, depths } }) => {
|
||||
function handleVerticalMove(index: number) {
|
||||
if (0 <= index && index < nodes.length) {
|
||||
DOMHelper.focusFileExplorer()
|
||||
|
|
@ -181,9 +180,14 @@ const handleKeyDown: MethodCreator<
|
|||
case 'Enter':
|
||||
// expand node or redirect to file page
|
||||
if (focusedNode.type === 'tree') {
|
||||
dispatch.call(setExpand, focusedNode, true)
|
||||
if (searched) {
|
||||
dispatch.call(goTo, focusedNode.path.split('/'))
|
||||
} else {
|
||||
dispatch.call(setExpand, focusedNode, true)
|
||||
}
|
||||
} else if (focusedNode.type === 'blob') {
|
||||
if (focusedNode.url) DOMHelper.loadWithPJAX(focusedNode.url)
|
||||
if (searched) dispatch.call(goTo, focusedNode.path.split('/'))
|
||||
else if (focusedNode.url) DOMHelper.loadWithPJAX(focusedNode.url)
|
||||
} else if (focusedNode.type === 'commit') {
|
||||
window.open(focusedNode.url)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue