File tree 8 files changed +67
-6
lines changed
8 files changed +67
-6
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ class Dialog extends Popup {
127
127
}
128
128
129
129
get _ariaLabelledBy ( ) { // Required by Popup.js
130
- return "ui5-popup-header" ;
130
+ return this . ariaLabel ? undefined : "ui5-popup-header" ;
131
131
}
132
132
133
133
get _ariaModal ( ) { // Required by Popup.js
Original file line number Diff line number Diff line change @@ -272,6 +272,8 @@ const metadata = {
272
272
} ,
273
273
274
274
/**
275
+ * Defines the aria-label attribute for the input
276
+ *
275
277
* @type {String }
276
278
* @since 1.0.0-rc.8
277
279
* @private
Original file line number Diff line number Diff line change @@ -599,7 +599,7 @@ class Popover extends Popup {
599
599
}
600
600
601
601
get _ariaLabelledBy ( ) { // Required by Popup.js
602
- return "ui5-popup-header" ;
602
+ return this . ariaLabel ? undefined : "ui5-popup-header" ;
603
603
}
604
604
605
605
get _ariaModal ( ) { // Required by Popup.js
Original file line number Diff line number Diff line change 1
- <section style =" {{ styles.root }} " class =" {{ classes.root }} " role =" dialog" aria-modal =" {{ _ariaModal }} " aria-labelledby =" {{ _ariaLabelledBy }} " >
1
+ <section
2
+ style =" {{ styles.root }} "
3
+ class =" {{ classes.root }} "
4
+ role =" dialog"
5
+ aria-modal =" {{ _ariaModal }} "
6
+ aria-label =" {{ _ariaLabel }} "
7
+ aria-labelledby =" {{ _ariaLabelledBy }} "
8
+ >
2
9
3
10
<span class =" first-fe" data-ui5-focus-trap tabindex =" 0" @focusin ={{ forwardToLast }} ></span >
4
11
Original file line number Diff line number Diff line change @@ -48,6 +48,19 @@ const metadata = {
48
48
type : Boolean ,
49
49
} ,
50
50
51
+ /**
52
+ * Defines the aria-label attribute for the popup
53
+ *
54
+ * @type {String }
55
+ * @defaultvalue : ""
56
+ * @private
57
+ * @since 1.0.0-rc.8
58
+ */
59
+ ariaLabel : {
60
+ type : String ,
61
+ defaultValue : undefined ,
62
+ } ,
63
+
51
64
/**
52
65
* @private
53
66
*/
@@ -390,6 +403,14 @@ class Popup extends UI5Element {
390
403
*/
391
404
get _ariaModal ( ) { } // eslint-disable-line
392
405
406
+ /**
407
+ * Ensures ariaLabel is never null or empty string
408
+ * @returns {String|undefined }
409
+ * @protected
410
+ */
411
+ get _ariaLabel ( ) {
412
+ return this . ariaLabel || undefined ;
413
+ }
393
414
394
415
get styles ( ) {
395
416
return {
Original file line number Diff line number Diff line change 60
60
61
61
< ui5-button id ="btn "> Click me !</ ui5-button >
62
62
63
- < ui5-popover header-text ="My Heading " id ="pop " style ="width: 300px " placement-type ="Top ">
63
+ < ui5-popover header-text ="My Heading " id ="pop " style ="width: 300px " placement-type ="Top " aria-label =" This popover is important " >
64
64
< div slot ="header ">
65
65
< ui5-button id ="first-focusable "> I am in the header</ ui5-button >
66
66
</ div >
355
355
</ script >
356
356
</ body >
357
357
358
- </ html >
358
+ </ html >
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ describe("Dialog general interaction", () => {
10
10
btnOpenDialog . click ( ) ;
11
11
12
12
const dialog = browser . $ ( "#dialog" ) ;
13
-
13
+
14
14
assert . ok ( dialog . isDisplayedInViewport ( ) , "Dialog is opened." ) ;
15
15
16
16
btnCloseDialog . click ( ) ;
@@ -32,3 +32,19 @@ describe("Dialog general interaction", () => {
32
32
assert . ok ( popoverZIndex > dialogZIndex , "Popover is above dialog." ) ;
33
33
} ) ;
34
34
} ) ;
35
+
36
+
37
+ describe ( "Acc" , ( ) => {
38
+ browser . url ( "http://localhost:8080/test-resources/pages/Dialog.html" ) ;
39
+
40
+ it ( "tests aria-labelledby and aria-label" , ( ) => {
41
+ const dialog = browser . $ ( "ui5-dialog" ) ;
42
+ dialog . removeAttribute ( "aria-label" ) ;
43
+ assert . ok ( dialog . shadow$ ( ".ui5-popup-root" ) . getAttribute ( "aria-labelledby" ) . length , "dialog has aria-labelledby." ) ;
44
+ assert . ok ( ! dialog . shadow$ ( ".ui5-popup-root" ) . getAttribute ( "aria-label" ) , "dialog does not have aria-label." ) ;
45
+
46
+ dialog . setAttribute ( "aria-label" , "text" ) ;
47
+ assert . ok ( ! dialog . shadow$ ( ".ui5-popup-root" ) . getAttribute ( "aria-labelledby" ) , "dialog does not have aria-labelledby." ) ;
48
+ assert . ok ( dialog . shadow$ ( ".ui5-popup-root" ) . getAttribute ( "aria-label" ) . length , "dialog has aria-label." ) ;
49
+ } ) ;
50
+ } ) ;
Original file line number Diff line number Diff line change @@ -180,3 +180,18 @@ describe("Popover general interaction", () => {
180
180
assert . ok ( ff . getProperty ( "focused" ) , "The first focusable element is focused." ) ;
181
181
} ) ;
182
182
} ) ;
183
+
184
+ describe ( "Acc" , ( ) => {
185
+ browser . url ( "http://localhost:8080/test-resources/pages/Popover.html" ) ;
186
+
187
+ it ( "tests aria-labelledby and aria-label" , ( ) => {
188
+ const popover = browser . $ ( "ui5-popover" ) ;
189
+ popover . removeAttribute ( "aria-label" ) ;
190
+ assert . ok ( popover . shadow$ ( ".ui5-popup-root" ) . getAttribute ( "aria-labelledby" ) . length , "Popover has aria-labelledby." ) ;
191
+ assert . ok ( ! popover . shadow$ ( ".ui5-popup-root" ) . getAttribute ( "aria-label" ) , "Popover does not have aria-label." ) ;
192
+
193
+ popover . setAttribute ( "aria-label" , "text" ) ;
194
+ assert . ok ( ! popover . shadow$ ( ".ui5-popup-root" ) . getAttribute ( "aria-labelledby" ) , "Popover does not have aria-labelledby." ) ;
195
+ assert . ok ( popover . shadow$ ( ".ui5-popup-root" ) . getAttribute ( "aria-label" ) . length , "Popover has aria-label." ) ;
196
+ } ) ;
197
+ } ) ;
You can’t perform that action at this time.
0 commit comments