Skip to content

Commit

Permalink
fix(ui5-textarea): enhance aria-invalid attribute handling (#4767)
Browse files Browse the repository at this point in the history
  • Loading branch information
niyap committed Feb 17, 2022
1 parent f8dc9f0 commit f2fd6fb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/main/src/TextArea.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<div
class="ui5-textarea-root"
style="{{styles.main}}"
?aria-invalid="{{ariaInvalid}}"
@focusin="{{_onfocusin}}"
@focusout="{{_onfocusout}}"
>
Expand All @@ -23,6 +22,7 @@
?readonly="{{readonly}}"
aria-label="{{ariaLabelText}}"
aria-describedby="{{ariaDescribedBy}}"
aria-invalid="{{ariaInvalid}}"
aria-required="{{required}}"
maxlength="{{_exceededTextProps.calcedMaxLength}}"
.value="{{value}}"
Expand Down
10 changes: 10 additions & 0 deletions packages/main/test/specs/Input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,16 @@ describe("Input general interaction", () => {
assert.strictEqual(await innerInput.getAttribute("aria-label"), NEW_TEXT, "aria-label is reflected in the shadow DOM")
});

it("Checks if aria-invalid is set correctly", async () => {
const inputError = await browser.$("#inputError");
const inputWarning = await browser.$("#input1");
const innerInputError = await inputError.shadow$("input");
const innerInputWarning = await inputWarning.shadow$("input");

assert.notOk(await innerInputWarning.getAttribute("aria-invalid"), "aria-invalid is not rendered");
assert.strictEqual(await innerInputError.getAttribute("aria-invalid"), "true", "aria-invalid is set to true");
});

it("Tests suggestions highlighting", async () => {
const input = await browser.$("#myInputHighlighted").shadow$("input");
const staticAreaItemClassName = await browser.getStaticAreaItemClassName("#myInputHighlighted");
Expand Down
10 changes: 10 additions & 0 deletions packages/main/test/specs/TextArea.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ describe("Attributes propagation", () => {
assert.strictEqual(await textArea2.getAttribute("aria-label"), EXPECTED_ARIA_LABEL2,
"The aria-label is correctly set internally.");
});

it("Checks if aria-invalid is set correctly", async () => {
const textAreaError = await browser.$("#basic-textarea-error");
const textAreaWarning = await browser.$("#basic-textarea-warning");
const innertextAreaError = await textAreaError.shadow$("textarea");
const innertextAreaWarning = await textAreaWarning.shadow$("textarea");

assert.notOk(await innertextAreaWarning.getAttribute("aria-invalid"), "aria-invalid is not rendered");
assert.strictEqual(await innertextAreaError.getAttribute("aria-invalid"), "true", "aria-invalid is set to true");
});
});

describe("disabled and readonly textarea", () => {
Expand Down

0 comments on commit f2fd6fb

Please sign in to comment.