File tree Expand file tree Collapse file tree 4 files changed +55
-3
lines changed Expand file tree Collapse file tree 4 files changed +55
-3
lines changed Original file line number Diff line number Diff line change 5
5
{{> busyRow }}
6
6
{{ /if }}
7
7
8
- <table border =" 0" cellspacing =" 0" cellpadding =" 0" @keydown =" {{ _onkeydown }} " role =" table" >
8
+ <table border =" 0" cellspacing =" 0" cellpadding =" 0" @keydown =" {{ _onkeydown }} " role =" table" aria-label = " {{ tableAriaLabelText }} " >
9
9
<thead >
10
10
<tr
11
11
id =" {{ _columnHeader.id }} "
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import {
23
23
import getNormalizedTarget from "@ui5/webcomponents-base/dist/util/getNormalizedTarget.js" ;
24
24
import getActiveElement from "@ui5/webcomponents-base/dist/util/getActiveElement.js" ;
25
25
import { getLastTabbableElement , getTabbableElements } from "@ui5/webcomponents-base/dist/util/TabbableElements.js" ;
26
+ import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js" ;
26
27
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
27
28
import debounce from "@ui5/webcomponents-base/dist/util/debounce.js" ;
28
29
import isElementInView from "@ui5/webcomponents-base/dist/util/isElementInView.js" ;
@@ -252,6 +253,32 @@ const metadata = {
252
253
defaultValue : TableMode . None ,
253
254
} ,
254
255
256
+ /**
257
+ * Defines the accessible aria name of the component.
258
+ *
259
+ * @type {string }
260
+ * @defaultvalue : ""
261
+ * @public
262
+ * @since 1.3.0
263
+ */
264
+ accessibleName : {
265
+ type : String ,
266
+ defaultValue : undefined ,
267
+ } ,
268
+
269
+ /**
270
+ * Receives id(or many ids) of the elements that label the component.
271
+ *
272
+ * @type {string }
273
+ * @defaultvalue ""
274
+ * @public
275
+ * @since 1.3.0
276
+ */
277
+ accessibleNameRef : {
278
+ type : String ,
279
+ defaultValue : "" ,
280
+ } ,
281
+
255
282
_hiddenColumns : {
256
283
type : Object ,
257
284
multiple : true ,
@@ -1117,6 +1144,10 @@ class Table extends UI5Element {
1117
1144
return `${ headerRowText } ${ columnsTitle } ` ;
1118
1145
}
1119
1146
1147
+ get tableAriaLabelText ( ) {
1148
+ return getEffectiveAriaLabelText ( this ) ;
1149
+ }
1150
+
1120
1151
get ariaLabelSelectAllText ( ) {
1121
1152
return Table . i18nBundle . getText ( ARIA_LABEL_SELECT_ALL_CHECKBOX ) ;
1122
1153
}
Original file line number Diff line number Diff line change 34
34
< button id ="toggleSticky " class ="table3auto "> Toggle Sticky Column Header</ button >
35
35
</ div >
36
36
37
- < ui5-table class ="demo-table " id ="tbl ">
37
+ < ui5-table class ="demo-table " accessible-name-ref =" tableLabel " id ="tbl ">
38
38
<!-- Columns -->
39
39
< ui5-table-column id ="column-1 " slot ="columns " width ="350px ">
40
40
< ui5-label > Product</ ui5-label >
133
133
134
134
<!-- 1 column, but 3 cells -->
135
135
< ui5-title > 1 column, but 3 cells</ ui5-title >
136
- < ui5-table class ="demo-table " id ="tblLessColumns ">
136
+ < ui5-table class ="demo-table " id ="tblLessColumns " accessible-name =" Table label " >
137
137
< ui5-table-column id ="column-1 " slot ="columns ">
138
138
< ui5-label > City</ ui5-label >
139
139
</ ui5-table-column >
Original file line number Diff line number Diff line change @@ -79,6 +79,27 @@ describe("Table general interaction", () => {
79
79
"The aria-label value is correct." ) ;
80
80
} ) ;
81
81
82
+ describe ( "Accessibility" , ( ) => {
83
+ before ( async ( ) => {
84
+ await browser . url ( `http://localhost:${ PORT } /test-resources/pages/Table.html` ) ;
85
+ } ) ;
86
+
87
+ it ( "Should apply aria-label from the accessibleName property" , async ( ) => {
88
+ const table = await browser . $ ( "#tblLessColumns" ) ;
89
+ const innerTable = await table . shadow$ ( "table" ) ;
90
+
91
+ assert . strictEqual ( await innerTable . getAttribute ( "aria-label" ) , "Table label" , "Table aria-label attribute is correct." ) ;
92
+ } ) ;
93
+
94
+ it ( "Should apply aria-label from the accessibleNameRef property" , async ( ) => {
95
+ const table = await browser . $ ( "#tbl" ) ;
96
+ const innerTable = await table . shadow$ ( "table" ) ;
97
+ const tableLabel = await browser . $ ( "#tableLabel" ) ;
98
+
99
+ assert . strictEqual ( await innerTable . getAttribute ( "aria-label" ) , await tableLabel . getHTML ( false ) , "Table aria-label attribute is correct." ) ;
100
+ } ) ;
101
+ } ) ;
102
+
82
103
describe ( "Growing Table on 'More' button press" , ( ) => {
83
104
it ( "tests the 'load-more' event" , async ( ) => {
84
105
await browser . url ( `http://localhost:${ PORT } /test-resources/pages/TableGrowingWithButton.html` ) ;
You can’t perform that action at this time.
0 commit comments