Skip to content

Commit e1c152c

Browse files
authoredMar 20, 2025··
fix(ui5-tree): noDataText is now properly rendered (SAP#11095)
There was a problem where noDataText wasn't rendered even if there are no tree items in the tree. This is because there was a an internal element counted as a child of the tree in its tsx template. With this fix, the noDataText is now properly rendered when there are no tree items in the tree. Fixes: SAP#11073
1 parent db269e8 commit e1c152c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
 

‎packages/main/cypress/specs/Tree.cy.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,21 @@ describe("Tree Tests", () => {
2828
.and("have.attr", "accessible-description-ref", "lblDesc2");
2929
});
3030
});
31+
32+
describe("Tree Props", () => {
33+
it("noDataText is properly rendered", () => {
34+
cy.mount(
35+
<>
36+
<Tree noDataText="No data"></Tree>
37+
</>
38+
);
39+
40+
cy.get("[ui5-tree]")
41+
.shadow()
42+
.find("[ui5-tree-list]")
43+
.shadow()
44+
.find("[ui5-busy-indicator]")
45+
.find(".ui5-list-nodata")
46+
.should("exist")
47+
});
48+
});

‎packages/main/src/TreeList.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ class TreeList extends List {
1212
const slottedItems = this.getSlottedNodes<TreeItemBase>("items");
1313
const flatItems: Array<TreeItemBase> = [];
1414

15-
flattenTree(slottedItems, flatItems, includeCollapsed);
15+
if (!(slottedItems.length === 1 && slottedItems[0].hasAttribute("ui5-drop-indicator"))) {
16+
flattenTree(slottedItems, flatItems, includeCollapsed);
17+
}
1618

1719
return flatItems;
1820
}

0 commit comments

Comments
 (0)