@@ -6,7 +6,7 @@ import { isIE } from "@ui5/webcomponents-base/dist/Device.js";
6
6
import { getLastTabbableElement } from "@ui5/webcomponents-base/dist/util/TabbableElements.js" ;
7
7
import { isTabNext , isSpace , isEnter } from "@ui5/webcomponents-base/dist/Keys.js" ;
8
8
import NavigationMode from "@ui5/webcomponents-base/dist/types/NavigationMode.js" ;
9
- import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper .js" ;
9
+ import findNodeOwner from "@ui5/webcomponents-base/dist/util/findNodeOwner .js" ;
10
10
import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
11
11
import debounce from "@ui5/webcomponents-base/dist/util/debounce.js" ;
12
12
import isElementInView from "@ui5/webcomponents-base/dist/util/isElementInView.js" ;
@@ -185,12 +185,14 @@ const metadata = {
185
185
} ,
186
186
187
187
/**
188
+ * Sets the accessible aria name of the component.
189
+ *
188
190
* @type {String }
189
191
* @defaultvalue ""
190
- * @private
191
- * @since 1.0.0-rc.8
192
+ * @public
193
+ * @since 1.0.0-rc.15
192
194
*/
193
- ariaLabel : {
195
+ accessibleName : {
194
196
type : String ,
195
197
} ,
196
198
@@ -199,21 +201,19 @@ const metadata = {
199
201
*
200
202
* @type {String }
201
203
* @defaultvalue ""
202
- * @private
203
- * @since 1.0.0-rc.8
204
+ * @public
205
+ * @since 1.0.0-rc.15
204
206
*/
205
- ariaLabelledby : {
207
+ accessibleNameRef : {
206
208
type : String ,
207
209
defaultValue : "" ,
208
210
} ,
209
211
210
212
/**
211
213
* Defines the accessible role of the component.
212
214
* <br><br>
213
- * <b>Note:</b> If you use notification list items,
214
- * it's recommended to set <code>accessible-role="list"</code> for better accessibility.
215
215
*
216
- * @private
216
+ * @public
217
217
* @type {String }
218
218
* @defaultvalue "list"
219
219
* @since 1.0.0-rc.15
@@ -459,6 +459,35 @@ class List extends UI5Element {
459
459
}
460
460
}
461
461
462
+ getEffectiveAriaLabelText ( el ) {
463
+ if ( ! el . accessibleNameRef ) {
464
+ if ( el . accessibleName ) {
465
+ return el . accessibleName ;
466
+ }
467
+
468
+ return undefined ;
469
+ }
470
+
471
+ return this . getAriaLabelledByTexts ( el ) ;
472
+ } ;
473
+
474
+ getAriaLabelledByTexts ( el , ownerDocument , readyIds = "" ) {
475
+ const ids = ( readyIds && readyIds . split ( " " ) ) || el . accessibleNameRef . split ( " " ) ;
476
+ const owner = ownerDocument || findNodeOwner ( el ) ;
477
+ let result = "" ;
478
+
479
+ ids . forEach ( ( elementId , index ) => {
480
+ const element = owner . querySelector ( `[id='${ elementId } ']` ) ;
481
+ result += `${ element ? element . textContent : "" } ` ;
482
+
483
+ if ( index < ids . length - 1 ) {
484
+ result += " " ;
485
+ }
486
+ } ) ;
487
+
488
+ return result ;
489
+ } ;
490
+
462
491
get shouldRenderH1 ( ) {
463
492
return ! this . header . length && this . headerText ;
464
493
}
@@ -482,17 +511,17 @@ class List extends UI5Element {
482
511
get isMultiSelect ( ) {
483
512
return this . mode === ListMode . MultiSelect ;
484
513
}
485
-
514
+
486
515
get ariaLabelledBy ( ) {
487
- if ( this . ariaLabelledby || this . ariaLabel ) {
516
+ if ( this . accessibleNameRef || this . accessibleName ) {
488
517
return undefined ;
489
518
}
490
-
519
+
491
520
return this . shouldRenderH1 ? this . headerID : undefined ;
492
521
}
493
-
522
+
494
523
get ariaLabelТxt ( ) {
495
- return getEffectiveAriaLabelText ( this ) ;
524
+ return this . getEffectiveAriaLabelText ( this ) ;
496
525
}
497
526
498
527
get grows ( ) {
0 commit comments