Skip to content

fix(ui5-tree): noDataText is now properly rendered #11095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 20, 2025
18 changes: 18 additions & 0 deletions packages/main/cypress/specs/Tree.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,21 @@ describe("Tree Tests", () => {
.and("have.attr", "accessible-description-ref", "lblDesc2");
});
});

describe("Tree Props", () => {
it("noDataText is properly rendered", () => {
cy.mount(
<>
<Tree noDataText="No data"></Tree>
</>
);

cy.get("[ui5-tree]")
.shadow()
.find("[ui5-tree-list]")
.shadow()
.find("[ui5-busy-indicator]")
.find(".ui5-list-nodata")
.should("exist")
});
});
4 changes: 3 additions & 1 deletion packages/main/src/TreeList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class TreeList extends List {
const slottedItems = this.getSlottedNodes<TreeItemBase>("items");
const flatItems: Array<TreeItemBase> = [];

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

return flatItems;
}
Expand Down