File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
Original file line number Diff line number Diff line change @@ -232,6 +232,10 @@ class ListItemGroup extends UI5Element {
232
232
233
233
this . dropIndicatorDOM ! . targetReference = null ;
234
234
}
235
+
236
+ getFocusDomRef ( ) {
237
+ return this . groupHeaderItem || this . items . at ( 0 ) ;
238
+ }
235
239
}
236
240
237
241
ListItemGroup . define ( ) ;
You can’t perform that action at this time.
0 commit comments