File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ class TreeListItem extends ListItem {
176
176
get _accInfo ( ) {
177
177
return {
178
178
role : "treeitem" ,
179
- ariaExpanded : this . expanded ,
179
+ ariaExpanded : this . showToggleButton ? this . expanded : undefined ,
180
180
ariaLevel : this . level ,
181
181
} ;
182
182
}
Original file line number Diff line number Diff line change @@ -71,12 +71,30 @@ describe("Tree has screen reader support", () => {
71
71
it ( "List item acc attributes correct" , ( ) => {
72
72
const tree = browser . $ ( "#tree" ) ;
73
73
const listItems = tree . shadow$$ ( "ui5-li-tree" ) ;
74
- listItems . forEach ( item => {
74
+
75
+ listItems . forEach ( ( item , idx ) => {
75
76
const li = item . shadow$ ( "li" ) ;
77
+ const itemExpandable = item . getProperty ( "showToggleButton" ) ;
78
+ const itemExpanded = item . getProperty ( "expanded" ) ;
79
+ const liAriaExpanded = li . getAttribute ( "aria-expanded" ) ;
80
+
81
+ const ariaExpandedValues = {
82
+ // (1) expandable: aria-expanded can be 'true' or 'false'
83
+ "true" : {
84
+ "true" : "true" ,
85
+ "false" : "false" ,
86
+ } ,
87
+ // (2) not expandable: aria-expanded is null - not present
88
+ "false" : {
89
+ "true" : null ,
90
+ "false" : null ,
91
+ }
92
+ } ;
76
93
77
94
assert . ok ( li . getAttribute ( "role" ) === "treeitem" , "List item role is correct" ) ;
78
95
assert . ok ( li . getAttribute ( "aria-level" ) === item . getAttribute ( "level" ) , "aria level is correct" ) ;
79
- assert . ok ( li . getAttribute ( "aria-expanded" ) === item . getAttribute ( "expanded" ) , "aria expanded is correct" ) ;
96
+ assert . equal ( liAriaExpanded , ariaExpandedValues [ itemExpandable ] [ itemExpanded ] ,
97
+ "aria-expanded is correct." ) ;
80
98
} ) ;
81
99
82
100
} ) ;
You can’t perform that action at this time.
0 commit comments