Skip to content

Commit

Permalink
Handle open empty folder
Browse files Browse the repository at this point in the history
  • Loading branch information
mbraak committed Nov 13, 2024
1 parent 8da7a2e commit 1469301
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/jqTree/methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,15 @@ describe("openNode", () => {
});
});
});

it("handles an empty folder", () => {
const child1 = given.$tree.tree("getNodeByNameMustExist", "child1");
child1.isEmptyFolder = true;

expect(() => {
given.$tree.tree("openNode", child1, false);
}).not.toThrow();
});
});

describe("prependNode", () => {
Expand Down
4 changes: 4 additions & 0 deletions src/tree.jquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,10 @@ export class JqTreeWidget extends SimpleWidget<JQTreeOptions> {
_slide: boolean,
_onFinished?: OnFinishOpenNode,
): void => {
if (!node.children.length) {
return;
}

const folderElement = this.createFolderElement(_node);
folderElement.open(
_onFinished,
Expand Down

0 comments on commit 1469301

Please sign in to comment.