mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: visible nodes are not always available
This commit is contained in:
parent
76c7c25990
commit
dff92bde6c
2 changed files with 9 additions and 3 deletions
|
|
@ -24,6 +24,7 @@ class FileExplorer extends React.Component<Props & ConnectorState> {
|
|||
freeze: false,
|
||||
searchKey: '',
|
||||
searched: false,
|
||||
visibleNodes: null,
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { raiseError } from 'analytics'
|
|||
|
||||
export type ConnectorState = {
|
||||
stateText: string
|
||||
visibleNodes: VisibleNodes
|
||||
visibleNodes: VisibleNodes | null
|
||||
searchKey: string
|
||||
searched: boolean
|
||||
|
||||
|
|
@ -141,7 +141,9 @@ const handleKeyDown: MethodCreator<
|
|||
ConnectorState,
|
||||
[React.KeyboardEvent]
|
||||
> = dispatch => event =>
|
||||
dispatch.get(({ searched, visibleNodes: { nodes, focusedNode, expandedNodes, depths } }) => {
|
||||
dispatch.get(({ searched, visibleNodes }) => {
|
||||
if (!visibleNodes) return
|
||||
const { nodes, focusedNode, expandedNodes, depths } = visibleNodes
|
||||
function handleVerticalMove(index: number) {
|
||||
if (0 <= index && index < nodes.length) {
|
||||
DOMHelper.focusFileExplorer()
|
||||
|
|
@ -325,7 +327,9 @@ const focusNode: MethodCreator<Props, ConnectorState, [TreeNode | null, boolean]
|
|||
node: TreeNode | null,
|
||||
skipScroll = false,
|
||||
) =>
|
||||
dispatch.get(({ visibleNodes: { nodes } }) => {
|
||||
dispatch.get(({ visibleNodes }) => {
|
||||
if (!visibleNodes) return
|
||||
const { nodes } = visibleNodes
|
||||
visibleNodesGenerator.focusNode(node)
|
||||
if (node && !skipScroll) {
|
||||
// when focus a node not in viewport(by keyboard), scroll to it
|
||||
|
|
@ -354,6 +358,7 @@ const mountExpandingIndicator: MethodCreator<
|
|||
[TreeNode]
|
||||
> = dispatch => node =>
|
||||
dispatch.get(({ visibleNodes }) => {
|
||||
if (!visibleNodes) return
|
||||
const dummyVisibleNodes = {
|
||||
...visibleNodes,
|
||||
nodes: visibleNodes.nodes.slice(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue