Skip to content

Commit

Permalink
fix: leaf is not open on 1st click
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenvanduocit committed Feb 28, 2023
1 parent 91a4440 commit 3f09742
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/fns/openView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ export const openView = async (
): Promise<void> => {
let leaf: WorkspaceLeaf
let leafs = workspace.getLeavesOfType(id)
if (leafs.length == 0) {
createView(workspace, id, position)
if (leafs.length > 0) {
workspace.revealLeaf(leafs[0])
return
}

leaf = workspace.getLeavesOfType(id)[0]
leaf = await createView(workspace, id, position)
workspace.revealLeaf(leaf)
return
}

const createView = (
const createView = async (
workspace: Workspace,
id: string,
position?: GateFrameOptionType
Expand All @@ -34,6 +35,6 @@ const createView = (
leaf = workspace.getRightLeaf(false)
break
}

leaf?.setViewState({ type: id, active: true })
await leaf?.setViewState({ type: id, active: true })
return leaf
}

0 comments on commit 3f09742

Please sign in to comment.