File tree 5 files changed +62
-1
lines changed
5 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import DateFormat from "@ui5/webcomponents-localization/dist/DateFormat.js";
9
9
import CalendarType from "@ui5/webcomponents-base/dist/types/CalendarType.js" ;
10
10
import CalendarDate from "@ui5/webcomponents-localization/dist/dates/CalendarDate.js" ;
11
11
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js" ;
12
+ import getEffectiveAriaLabelText from "@ui5/webcomponents-base/dist/util/getEffectiveAriaLabelText.js" ;
12
13
import { isShow , isF4 } from "@ui5/webcomponents-base/dist/Keys.js" ;
13
14
import { isPhone } from "@ui5/webcomponents-base/dist/Device.js" ;
14
15
import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
@@ -217,6 +218,31 @@ const metadata = {
217
218
type : Boolean ,
218
219
} ,
219
220
221
+ /**
222
+ * Defines the aria-label attribute for the <code>ui5-date-picker</code>.
223
+ *
224
+ * @type {String }
225
+ * @since 1.0.0-rc.9
226
+ * @private
227
+ * @defaultvalue ""
228
+ */
229
+ ariaLabel : {
230
+ type : String ,
231
+ } ,
232
+
233
+ /**
234
+ * Receives id(or many ids) of the elements that label the <code>ui5-date-picker</code>.
235
+ *
236
+ * @type {String }
237
+ * @defaultvalue ""
238
+ * @private
239
+ * @since 1.0.0-rc.9
240
+ */
241
+ ariaLabelledby : {
242
+ type : String ,
243
+ defaultValue : "" ,
244
+ } ,
245
+
220
246
_isPickerOpen : {
221
247
type : Boolean ,
222
248
noAttribute : true ,
@@ -660,6 +686,7 @@ class DatePicker extends UI5Element {
660
686
"ariaExpanded" : this . isOpen ( ) ,
661
687
"ariaDescription" : this . dateAriaDescription ,
662
688
"ariaRequired" : this . required ,
689
+ "ariaLabel" : getEffectiveAriaLabelText ( this ) ,
663
690
} ;
664
691
}
665
692
Original file line number Diff line number Diff line change @@ -1013,7 +1013,7 @@ class Input extends UI5Element {
1013
1013
"ariaOwns" : this . _inputAccInfo && this . _inputAccInfo . ariaOwns ,
1014
1014
"ariaExpanded" : this . _inputAccInfo && this . _inputAccInfo . ariaExpanded ,
1015
1015
"ariaDescription" : this . _inputAccInfo && this . _inputAccInfo . ariaDescription ,
1016
- "ariaLabel" : getEffectiveAriaLabelText ( this ) ,
1016
+ "ariaLabel" : ( this . _inputAccInfo && this . _inputAccInfo . ariaLabel ) || getEffectiveAriaLabelText ( this ) ,
1017
1017
"ariaRequired" : ( this . _inputAccInfo && this . _inputAccInfo . ariaRequired ) || this . required ,
1018
1018
} ,
1019
1019
} ;
Original file line number Diff line number Diff line change @@ -112,6 +112,14 @@ <h3>3 months range</h3>
112
112
< h3 > 1 year range</ h3 >
113
113
< ui5-date-picker id ="minMax4 " value ="5 Feb 2021 " min-date ="5 Jan 2020 " max-date ="5 Jan 2021 "> </ ui5-date-picker >
114
114
115
+ < section >
116
+ < h3 > Test ariaLabel and ariaLabelledBy</ h3 >
117
+ < ui5-date-picker id ="dpAriaLabel " aria-label ="Hello World "> </ ui5-date-picker >
118
+ < br >
119
+ < ui5-label id ="infoText "> info text</ ui5-label >
120
+ < ui5-date-picker id ="dpAriaLabelledBy " aria-labelledby ="infoText "> </ ui5-date-picker >
121
+ </ section >
122
+
115
123
< section class ="ui5-content-density-compact ">
116
124
< h3 > DatePicker in Compact</ h3 >
117
125
< div >
Original file line number Diff line number Diff line change @@ -70,6 +70,14 @@ <h3>DatePicker with hide-week-numbers=true/false</h3>
70
70
< ui5-date-picker id ="dp18 "> </ ui5-date-picker >
71
71
< ui5-date-picker id ="dp19 " hide-week-numbers > </ ui5-date-picker >
72
72
73
+ < section >
74
+ < h3 > Test ariaLabel and ariaLabelledBy</ h3 >
75
+ < ui5-date-picker id ="dpAriaLabel " aria-label ="Hello World "> </ ui5-date-picker >
76
+ < br >
77
+ < ui5-label id ="infoText "> info text</ ui5-label >
78
+ < ui5-date-picker id ="dpAriaLabelledBy " aria-labelledby ="infoText "> </ ui5-date-picker >
79
+ </ section >
80
+
73
81
< script >
74
82
var originalGetDate = Date . prototype . getDate ;
75
83
Original file line number Diff line number Diff line change @@ -717,4 +717,22 @@ describe("Date Picker Tests", () => {
717
717
datepicker . innerInput . click ( ) ;
718
718
browser . keys ( [ "Alt" , "ArrowUp" , "NULL" ] ) ;
719
719
} ) ;
720
+
721
+ it ( "Tests aria-label" , ( ) => {
722
+ const EXPECTED_ARIA_LABEL = "Hello World" ;
723
+
724
+ datepicker . id = "#dpAriaLabel" ;
725
+
726
+ assert . strictEqual ( datepicker . innerInput . getAttribute ( "aria-label" ) , EXPECTED_ARIA_LABEL ,
727
+ "The aria-label is correct." )
728
+ } ) ;
729
+
730
+ it ( "Tests aria-labelledby" , ( ) => {
731
+ const EXPECTED_ARIA_LABEL = "info text" ;
732
+
733
+ datepicker . id = "#dpAriaLabelledBy" ;
734
+
735
+ assert . strictEqual ( datepicker . innerInput . getAttribute ( "aria-label" ) , EXPECTED_ARIA_LABEL ,
736
+ "The aria-label is correct." )
737
+ } ) ;
720
738
} ) ;
You can’t perform that action at this time.
0 commit comments