File tree 4 files changed +59
-5
lines changed
4 files changed +59
-5
lines changed Original file line number Diff line number Diff line change 24
24
?readonly =" {{ readonly }} "
25
25
?required =" {{ required }} "
26
26
aria-required =" {{ required }} "
27
- aria-labelledby = {{ ariaLabelledBy }}
28
- aria-describedby ={{ ariaDescribedBy }}
27
+ aria-label = " {{ ariaLabelText }} "
28
+ aria-describedby =" {{ ariaDescribedBy }} "
29
29
maxlength =" {{ _exceededTextProps.calcedMaxLength }} "
30
30
.value =" {{ value }} "
31
31
@input =" {{ _oninput }} "
39
39
{{> afterTextarea }}
40
40
41
41
{{ #if showExceededText }}
42
- <span id = " {{ _id }} -exceededText " class =" ui5-textarea-exceeded-text" >{{ _exceededTextProps.exceededText }} </span >
42
+ <span class =" ui5-textarea-exceeded-text" >{{ _exceededTextProps.exceededText }} </span >
43
43
{{ /if }}
44
44
45
45
{{ #if hasValueState }}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2
2
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js" ;
3
3
import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js" ;
4
4
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js" ;
5
+ import getEffectiveAriaLabelText from "@ui5/webcomponents-base/dist/util/getEffectiveAriaLabelText.js" ;
5
6
import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
6
7
import { getFeature } from "@ui5/webcomponents-base/dist/FeaturesRegistry.js" ;
7
8
import { isIE } from "@ui5/webcomponents-base/dist/Device.js" ;
@@ -209,6 +210,31 @@ const metadata = {
209
210
type : String ,
210
211
} ,
211
212
213
+ /**
214
+ * Defines the aria-label attribute for the textarea.
215
+ *
216
+ * @type {String }
217
+ * @since 1.0.0-rc.9
218
+ * @private
219
+ * @defaultvalue ""
220
+ */
221
+ ariaLabel : {
222
+ type : String ,
223
+ } ,
224
+
225
+
226
+ /**
227
+ * Receives id(or many ids) of the elements that label the textarea.
228
+ *
229
+ * @type {String }
230
+ * @defaultvalue ""
231
+ * @private
232
+ * @since 1.0.0-rc.9
233
+ */
234
+ ariaLabelledby : {
235
+ type : String ,
236
+ } ,
237
+
212
238
/**
213
239
* @private
214
240
*/
@@ -539,8 +565,18 @@ class TextArea extends UI5Element {
539
565
return this . disabled ? undefined : "0" ;
540
566
}
541
567
542
- get ariaLabelledBy ( ) {
543
- return this . showExceededText ? `${ this . _id } -exceededText` : undefined ;
568
+ get ariaLabelText ( ) {
569
+ const effectiveAriaLabelText = getEffectiveAriaLabelText ( this ) ;
570
+
571
+ if ( this . showExceededText ) {
572
+ if ( effectiveAriaLabelText ) {
573
+ return `${ effectiveAriaLabelText } ${ this . _exceededTextProps . exceededText } ` ;
574
+ }
575
+
576
+ return this . _exceededTextProps . exceededText ;
577
+ }
578
+
579
+ return effectiveAriaLabelText ;
544
580
}
545
581
546
582
get ariaDescribedBy ( ) {
Original file line number Diff line number Diff line change 199
199
< ui5-textarea growing growing-max-lines ="4 "> </ ui5-textarea >
200
200
</ section >
201
201
202
+ < section class ="aria-label and aria-labelledby ">
203
+ < span id ="infoText "> info text</ span >
204
+ < ui5-textarea id ="textAreaAriaLabel " aria-label ="Hello World "> </ ui5-textarea >
205
+ < ui5-textarea id ="textAreaAriaLabelledBy " maxlength ="20 " show-exceeded-text aria-labelledby ="infoText " class ="fixed-width fixed-height "> </ ui5-textarea >
206
+ </ section >
207
+
202
208
< script >
203
209
var changeCounter = 0 ;
204
210
var inputCounter = 0 ;
Original file line number Diff line number Diff line change @@ -35,6 +35,18 @@ describe("Attributes propagation", () => {
35
35
36
36
assert . strictEqual ( browser . $ ( "#basic-textarea" ) . shadow$ ( "textarea" ) . getValue ( ) , sExpectedValue , "Value property was set correctly" ) ;
37
37
} ) ;
38
+
39
+ it ( "Tests aria-label and aria-labelledby" , ( ) => {
40
+ const textArea1 = browser . $ ( "#textAreaAriaLabel" ) . shadow$ ( "textarea" ) ;
41
+ const textArea2 = browser . $ ( "#textAreaAriaLabelledBy" ) . shadow$ ( "textarea" ) ;
42
+ const EXPECTED_ARIA_LABEL1 = "Hello World" ;
43
+ const EXPECTED_ARIA_LABEL2 = "info text 20 characters remaining" ;
44
+
45
+ assert . strictEqual ( textArea1 . getAttribute ( "aria-label" ) , EXPECTED_ARIA_LABEL1 ,
46
+ "The aria-label is correctly set internally." ) ;
47
+ assert . strictEqual ( textArea2 . getAttribute ( "aria-label" ) , EXPECTED_ARIA_LABEL2 ,
48
+ "The aria-label is correctly set internally." ) ;
49
+ } ) ;
38
50
} ) ;
39
51
40
52
describe ( "disabled and readonly textarea" , ( ) => {
You can’t perform that action at this time.
0 commit comments