feat(FileExplorer): focus on first content node

This commit is contained in:
EnixCoda 2018-06-15 00:25:26 +08:00
parent 64d9ab9482
commit 998a8aa093

View file

@ -116,6 +116,23 @@ export default class List extends React.Component {
// consider the two keys as 'confirm' key
case 'ArrowRight':
// expand node or focus on first content node or redirect to file page
if (focusedNode.type === 'tree') {
if (expandedNodes.has(focusedNode)) {
const nextNode = nodes[focusedNodeIndex + 1]
if (depths.get(nextNode) > depths.get(focusedNode)) {
this.focusNode(nextNode)
}
} else {
this.setExpand(focusedNode, true)
}
} else if (focusedNode.type === 'blob') {
DOMHelper.loadWithPJAX(focusedNode.url)
} else if (focusedNode.type === 'commit') {
// redirect to its parent folder
DOMHelper.loadWithPJAX(focusedNode.parent.url)
}
break
case 'Enter':
// expand node or redirect to file page
if (focusedNode.type === 'tree') {