@@ -4,6 +4,7 @@ import slideDown from "@ui5/webcomponents-base/dist/animations/slideDown.js";
4
4
import slideUp from "@ui5/webcomponents-base/dist/animations/slideUp.js" ;
5
5
import { isSpace , isEnter } from "@ui5/webcomponents-base/dist/Keys.js" ;
6
6
import AnimationMode from "@ui5/webcomponents-base/dist/types/AnimationMode.js" ;
7
+ import getEffectiveAriaLabelText from "@ui5/webcomponents-base/dist/util/getEffectiveAriaLabelText.js" ;
7
8
import { getAnimationMode } from "@ui5/webcomponents-base/dist/config/AnimationMode.js" ;
8
9
import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
9
10
import "@ui5/webcomponents-icons/dist/icons/navigation-right-arrow.js" ;
@@ -117,7 +118,27 @@ const metadata = {
117
118
type : TitleLevel ,
118
119
defaultValue : TitleLevel . H2 ,
119
120
} ,
120
-
121
+ /**
122
+ * @type {String }
123
+ * @defaultvalue ""
124
+ * @private
125
+ * @since 1.0.0-rc.8
126
+ */
127
+ ariaLabel : {
128
+ type : String ,
129
+ } ,
130
+ /**
131
+ * Receives id(or many ids) of the elements that label the panel
132
+ *
133
+ * @type {String }
134
+ * @defaultvalue ""
135
+ * @private
136
+ * @since 1.0.0-rc.8
137
+ */
138
+ ariaLabelledby : {
139
+ type : String ,
140
+ defaultValue : "" ,
141
+ } ,
121
142
/**
122
143
* @private
123
144
*/
@@ -342,10 +363,6 @@ class Panel extends UI5Element {
342
363
return ! this . collapsed ;
343
364
}
344
365
345
- get ariaLabelledBy ( ) {
346
- return this . header . length ? "" : `${ this . _id } -header` ;
347
- }
348
-
349
366
get accRole ( ) {
350
367
return this . accessibleRole . toLowerCase ( ) ;
351
368
}
@@ -357,12 +374,28 @@ class Panel extends UI5Element {
357
374
"ariaControls" : this . _hasHeader ? `${ this . _id } -content` : undefined ,
358
375
"title" : this . toggleButtonTitle ,
359
376
} ,
360
- "ariaExpanded" : ! this . _hasHeader ? this . expanded : undefined ,
361
- "ariaControls" : ! this . _hasHeader ? `${ this . _id } -content` : undefined ,
362
- "role" : ! this . _hasHeader ? "button" : undefined ,
377
+ "ariaExpanded" : this . nonFixedInternalHeader ? this . expanded : undefined ,
378
+ "ariaControls" : this . nonFixedInternalHeader ? `${ this . _id } -content` : undefined ,
379
+ "ariaLabelledby" : this . nonFocusableButton ? this . ariaLabelledbyReference : undefined ,
380
+ "ariaLabel" : this . nonFocusableButton ? this . ariaLabelTxt : undefined ,
381
+ "ariaLabelledbyButton" : this . nonFocusableButton ? undefined : this . ariaLabelledbyReference ,
382
+ "ariaLabelButton" : this . nonFocusableButton ? undefined : this . ariaLabelTxt ,
383
+ "role" : this . nonFixedInternalHeader ? "button" : undefined ,
363
384
} ;
364
385
}
365
386
387
+ get ariaLabelledbyReference ( ) {
388
+ if ( this . ariaLabelledby || this . ariaLabel ) {
389
+ return undefined ;
390
+ }
391
+
392
+ return ( this . nonFocusableButton && this . headerText ) ? `${ this . _id } -header-title` : undefined ;
393
+ }
394
+
395
+ get ariaLabelTxt ( ) {
396
+ return getEffectiveAriaLabelText ( this ) ;
397
+ }
398
+
366
399
get headerAriaLevel ( ) {
367
400
return this . headerLevel . slice ( 1 ) ;
368
401
}
@@ -371,6 +404,10 @@ class Panel extends UI5Element {
371
404
return ( this . header . length || this . fixed ) ? "-1" : "0" ;
372
405
}
373
406
407
+ get nonFixedInternalHeader ( ) {
408
+ return ! this . _hasHeader && ! this . fixed ;
409
+ }
410
+
374
411
get nonFocusableButton ( ) {
375
412
return ! this . header . length ;
376
413
}
0 commit comments