Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set aria-invalid true when invalid #2168

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/components/src/components/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class Checkbox {
indeterminate={this.indeterminate}
aria-label={this.ariaLabelCheckbox}
aria-checked={this.indeterminate ? 'mixed' : false}
aria-invalid={this.status === 'error' || this.invalid}
aria-invalid={this.status === 'error' || this.invalid ? 'true' : null}
aria-describedBy={helperText.id}
disabled={this.disabled}
required={this.required}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/dropdown/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class Dropdown {

render() {
const ariaInvalidAttr =
this.status === 'error' || this.invalid ? { 'aria-invalid': true } : {};
this.status === 'error' || this.invalid ? { 'aria-invalid': 'true' } : {};
const helperTextId = `helper-message-${this.internalId}`;
const ariaDescribedByAttr = { 'aria-describedBy': helperTextId };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`Input props should reflect attributes 1`] = `
label
</label>
<div class="input__select-wrapper">
<select aria-describedby="helper-message-13" aria-invalid="" class="input__select" id="input-13" name="name" required="" value=""></select>
<select aria-describedby="helper-message-13" aria-invalid="true" class="input__select" id="input-13" name="name" required="" value=""></select>
</div>
<div aria-live="polite" aria-relevant="additions removals" class="input__meta" id="helper-message-13">
<div class="input__helper-text">
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export class Input {
const Tag = this.type === 'textarea' ? 'textarea' : 'input';

const ariaInvalidAttr =
this.status === 'error' || this.invalid ? { 'aria-invalid': true } : {};
this.status === 'error' || this.invalid ? { 'aria-invalid': 'true' } : {};
const helperTextId = `helper-message-${this.internalId}`;
const ariaDescribedByAttr = { 'aria-describedBy': helperTextId };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class RadioButton {

render() {
const ariaInvalidAttr =
this.status === 'error' || this.invalid ? { 'aria-invalid': true } : {};
this.status === 'error' || this.invalid ? { 'aria-invalid': 'true' } : {};
const helperTextId = `helper-message-${this.internalId}`;
const ariaDescribedByAttr = { 'aria-describedBy': helperTextId };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class TextField {

render() {
const ariaInvalidAttr =
this.status === 'error' || this.invalid ? { 'aria-invalid': true } : {};
this.status === 'error' || this.invalid ? { 'aria-invalid': 'true' } : {};
const helperTextId = `helper-message-${this.internalId}`;
const ariaDescribedByAttr = { 'aria-describedBy': helperTextId };
const ariaDetailedById = { 'aria-details': this.ariaDetailedId };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports[`Textarea should match snapshot -> helpertext 1`] = `
<scale-textarea helper-text="helpertext" invalid="true">
<div class="textarea textarea--status-error textarea--variant-informational">
<div class="textarea__wrapper">
<label class="textarea__label" htmlfor="input-textarea-1"></label><textarea aria-describedby="helper-message-1" aria-invalid="" class="textarea__control" id="input-textarea-1" value=""></textarea>
<label class="textarea__label" htmlfor="input-textarea-1"></label><textarea aria-describedby="helper-message-1" aria-invalid="true" class="textarea__control" id="input-textarea-1" value=""></textarea>
</div>
<div aria-live="polite" aria-relevant="additions removals" class="textarea__meta" id="helper-message-1">
<scale-helper-text helpertext="helpertext" variant="danger"></scale-helper-text>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/textarea/textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class Textarea {

render() {
const ariaInvalidAttr =
this.status === 'error' || this.invalid ? { 'aria-invalid': true } : {};
this.status === 'error' || this.invalid ? { 'aria-invalid': 'true' } : {};
const helperTextId = `helper-message-${this.internalId}`;
const ariaDescribedByAttr = { 'aria-describedBy': helperTextId };
const readonlyAttr = this.readonly ? { readonly: 'readonly' } : {};
Expand Down
Loading