Skip to content

Commit e93ab67

Browse files
committed
chore: restore getters and add tests
1 parent e271627 commit e93ab67

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import List from "../../src/List.js";
2+
import ListItemStandard from "../../src/ListItemStandard.js";
3+
import ListItemGroup from "../../src/ListItemGroup.js";
4+
5+
describe("Focus", () => {
6+
it("getFocusDomRef should return header element if available", () => {
7+
cy.mount(
8+
<List>
9+
<ListItemGroup headerText="Group Header">
10+
<ListItemStandard>Item 1</ListItemStandard>
11+
<ListItemStandard>Item 2</ListItemStandard>
12+
<ListItemStandard>Item 3</ListItemStandard>
13+
</ListItemGroup>
14+
</List>
15+
);
16+
17+
cy.get<ListItemGroup>("[ui5-li-group]")
18+
.then(($el) => {
19+
const group = $el[0];
20+
expect(group.getFocusDomRef()).to.have.attr("ui5-li-group-header");
21+
});
22+
23+
});
24+
25+
it("getFocusDomRef should return list item when header is not available", () => {
26+
cy.mount(
27+
<List>
28+
<ListItemGroup>
29+
<ListItemStandard>Item 1</ListItemStandard>
30+
<ListItemStandard>Item 2</ListItemStandard>
31+
<ListItemStandard>Item 3</ListItemStandard>
32+
</ListItemGroup>
33+
</List>
34+
);
35+
36+
cy.get<ListItemGroup>("[ui5-li-group]")
37+
.then(($el) => {
38+
const group = $el[0];
39+
expect(group.getFocusDomRef()).to.have.attr("ui5-li");
40+
});
41+
});
42+
});

packages/main/src/ListItemGroup.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ class ListItemGroup extends UI5Element {
232232

233233
this.dropIndicatorDOM!.targetReference = null;
234234
}
235+
236+
getFocusDomRef() {
237+
return this.groupHeaderItem || this.items.at(0);
238+
}
235239
}
236240

237241
ListItemGroup.define();

0 commit comments

Comments
 (0)