Skip to content

Commit

Permalink
Handle open empty folder (#859)
Browse files Browse the repository at this point in the history
* Handle open empty folder

* Changelog
  • Loading branch information
mbraak authored Nov 13, 2024
1 parent 8da7a2e commit eb1d803
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/_entries/general/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: Changelog
name: changelog
---

#### Development version

- Issue #858: load on demand with empty children (thanks to Ivan Kolesov)

#### 1.8.7 (november 2 2024)

- Issue #853: fix dnd to first child (thanks to Oskar von Dungern)
Expand Down
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 eb1d803

Please sign in to comment.