@@ -4,6 +4,7 @@ import slideDown from "@ui5/webcomponents-base/dist/animations/slideDown.js";
44import slideUp from "@ui5/webcomponents-base/dist/animations/slideUp.js" ;
55import { isSpace , isEnter } from "@ui5/webcomponents-base/dist/Keys.js" ;
66import AnimationMode from "@ui5/webcomponents-base/dist/types/AnimationMode.js" ;
7+ import getEffectiveAriaLabelText from "@ui5/webcomponents-base/dist/util/getEffectiveAriaLabelText.js" ;
78import { getAnimationMode } from "@ui5/webcomponents-base/dist/config/AnimationMode.js" ;
89import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
910import "@ui5/webcomponents-icons/dist/icons/navigation-right-arrow.js" ;
@@ -116,7 +117,27 @@ const metadata = {
116117 type : TitleLevel ,
117118 defaultValue : TitleLevel . H2 ,
118119 } ,
119-
120+ /**
121+ * @type {String }
122+ * @defaultvalue ""
123+ * @private
124+ * @since 1.0.0-rc.8
125+ */
126+ ariaLabel : {
127+ type : String ,
128+ } ,
129+ /**
130+ * Receives id(or many ids) of the elements that label the panel
131+ *
132+ * @type {String }
133+ * @defaultvalue ""
134+ * @private
135+ * @since 1.0.0-rc.8
136+ */
137+ ariaLabelledby : {
138+ type : String ,
139+ defaultValue : "" ,
140+ } ,
120141 /**
121142 * @private
122143 */
@@ -341,10 +362,6 @@ class Panel extends UI5Element {
341362 return ! this . collapsed ;
342363 }
343364
344- get ariaLabelledBy ( ) {
345- return this . header . length ? "" : `${ this . _id } -header` ;
346- }
347-
348365 get accRole ( ) {
349366 return this . accessibleRole . toLowerCase ( ) ;
350367 }
@@ -356,12 +373,28 @@ class Panel extends UI5Element {
356373 "ariaControls" : this . _hasHeader ? `${ this . _id } -content` : undefined ,
357374 "title" : this . toggleButtonTitle ,
358375 } ,
359- "ariaExpanded" : ! this . _hasHeader ? this . expanded : undefined ,
360- "ariaControls" : ! this . _hasHeader ? `${ this . _id } -content` : undefined ,
361- "role" : ! this . _hasHeader ? "button" : undefined ,
376+ "ariaExpanded" : this . nonFixedInternalHeader ? this . expanded : undefined ,
377+ "ariaControls" : this . nonFixedInternalHeader ? `${ this . _id } -content` : undefined ,
378+ "ariaLabelledby" : this . nonFocusableButton ? this . ariaLabelledbyReference : undefined ,
379+ "ariaLabel" : this . nonFocusableButton ? this . ariaLabelTxt : undefined ,
380+ "ariaLabelledbyButton" : this . nonFocusableButton ? undefined : this . ariaLabelledbyReference ,
381+ "ariaLabelButton" : this . nonFocusableButton ? undefined : this . ariaLabelTxt ,
382+ "role" : this . nonFixedInternalHeader ? "button" : undefined ,
362383 } ;
363384 }
364385
386+ get ariaLabelledbyReference ( ) {
387+ if ( this . ariaLabelledby || this . ariaLabel ) {
388+ return undefined ;
389+ }
390+
391+ return ( this . nonFocusableButton && this . headerText ) ? `${ this . _id } -header-title` : undefined ;
392+ }
393+
394+ get ariaLabelTxt ( ) {
395+ return getEffectiveAriaLabelText ( this ) ;
396+ }
397+
365398 get headerAriaLevel ( ) {
366399 return this . headerLevel . slice ( 1 ) ;
367400 }
@@ -370,6 +403,10 @@ class Panel extends UI5Element {
370403 return ( this . header . length || this . fixed ) ? "-1" : "0" ;
371404 }
372405
406+ get nonFixedInternalHeader ( ) {
407+ return ! this . _hasHeader && ! this . fixed ;
408+ }
409+
373410 get nonFocusableButton ( ) {
374411 return ! this . header . length ;
375412 }
0 commit comments