@@ -66,6 +66,19 @@ const metadata = {
6666 action : {
6767 type : HTMLElement ,
6868 } ,
69+
70+ /**
71+ * Defines the accessible name of the component, which is used as the name of the card region and should be unique per card.
72+ * <b>Note:</b> <code>accessibleName</code> should be always set.
73+ *
74+ * @type {String }
75+ * @defaultvalue ""
76+ * @public
77+ * @since 1.0.0-rc.16
78+ */
79+ accessibleName : {
80+ type : String ,
81+ } ,
6982 } ,
7083 properties : /** @lends sap.ui.webcomponents.main.Card.prototype */ {
7184
@@ -255,12 +268,39 @@ class Card extends UI5Element {
255268 return ! ! ( this . heading || this . subheading || this . status || this . hasAction || this . avatar ) ;
256269 }
257270
271+ getEffectiveAriaLabelText ( el ) {
272+ if ( ! el . accessibleNameRef ) {
273+ if ( el . accessibleName ) {
274+ return el . accessibleName ;
275+ }
276+
277+ return undefined ;
278+ }
279+
280+ return this . getAriaLabelledByTexts ( el ) ;
281+ } ;
282+
283+ getAriaLabelledByTexts ( el , ownerDocument , readyIds = "" ) {
284+ const ids = ( readyIds && readyIds . split ( " " ) ) || el . accessibleNameRef . split ( " " ) ;
285+ const owner = ownerDocument || findNodeOwner ( el ) ;
286+ let result = "" ;
287+
288+ ids . forEach ( ( elementId , index ) => {
289+ const element = owner . querySelector ( `[id='${ elementId } ']` ) ;
290+ result += `${ element ? element . textContent : "" } ` ;
291+
292+ if ( index < ids . length - 1 ) {
293+ result += " " ;
294+ }
295+ } ) ;
296+
297+ return result ;
298+ } ;
299+
258300 get ariaLabelText ( ) {
259- return getEffectiveAriaLabelText ( this ) ;
260- }
261-
262- get ariaCardRoleDescription ( ) {
263- return this . i18nBundle . getText ( ARIA_ROLEDESCRIPTION_CARD ) ;
301+ const effectiveAriaLabelText = getEffectiveAriaLabelText ( this ) ,
302+ effectiveAriaLabel = effectiveAriaLabelText ? ` ${ effectiveAriaLabelText } ` : "" ;
303+ return this . i18nBundle . getText ( ARIA_ROLEDESCRIPTION_CARD ) + effectiveAriaLabel ;
264304 }
265305
266306 get ariaCardHeaderRoleDescription ( ) {
@@ -293,10 +333,6 @@ class Card extends UI5Element {
293333 return labels . length !== 0 ? labels . join ( " " ) : undefined ;
294334 }
295335
296- get ariaLabelledByCard ( ) {
297- return this . heading ? `${ this . _id } -heading ${ this . _id } -desc` : `${ this . _id } -desc` ;
298- }
299-
300336 get hasAvatar ( ) {
301337 return ! ! this . avatar . length ;
302338 }
0 commit comments