Skip to content

Commit

Permalink
fix(ui5-textarea): announce custom valueStateMessage (#2122)
Browse files Browse the repository at this point in the history
FIXES #2106
  • Loading branch information
ilhan007 authored Aug 19, 2020
1 parent 1971a54 commit 4d27065
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/main/src/TextArea.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
?required="{{required}}"
aria-required="{{required}}"
aria-labelledby={{ariaLabelledBy}}
aria-describedby={{ariaDescribedBy}}
maxlength="{{_exceededTextProps.calcedMaxLength}}"
.value="{{value}}"
@input="{{_oninput}}"
Expand All @@ -41,6 +42,10 @@
<span id="{{_id}}-exceededText" class="ui5-textarea-exceeded-text">{{_exceededTextProps.exceededText}}</span>
{{/if}}

{{#if hasValueState}}
<span id="{{_id}}-valueStateDesc" class="ui5-hidden-text">{{ariaValueStateHiddenText}}</span>
{{/if}}

<slot name="formSupport"></slot>
</div>

Expand Down
16 changes: 16 additions & 0 deletions packages/main/src/TextArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,22 @@ class TextArea extends UI5Element {
return this.showExceededText ? `${this._id}-exceededText` : undefined;
}

get ariaDescribedBy() {
return this.hasValueState ? `${this._id}-valueStateDesc` : undefined;
}

get ariaValueStateHiddenText() {
if (!this.hasValueState) {
return;
}

if (this.hasCustomValueState) {
return this.valueStateMessageText.map(el => el.textContent).join(" ");
}

return this.valueStateText;
}

get ariaInvalid() {
return this.valueState === "Error" ? "true" : undefined;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/main/src/themes/TextArea.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "./InvisibleTextStyles.css";

:host(:not([hidden])) {
display: inline-block;
}
Expand Down

0 comments on commit 4d27065

Please sign in to comment.