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(#2028): add accessibility features #2057

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

syedszeeshan
Copy link
Collaborator

@syedszeeshan syedszeeshan commented Aug 7, 2024

Before (the change)

After (the change)

-The code adds appropriate aria-* attributes based on whether a field is required, has helper text and/or error text or both.
-When focused, the screen reader announces the helper text and/or error text

Make sure that you've checked the boxes below before you submit the PR

  • I have read and followed the setup steps
  • I have created necessary unit tests
  • I have tested the functionality in both React and Angular.

Steps needed to test

Playground Test Code

import { Component } from "@angular/core";
import { FormBuilder, FormControl, FormGroup, Validators } from "@angular/forms";

@Component({
  selector: "abgov-radio",
  templateUrl: "./radio.component.html",
  styleUrls: ["./radio.component.css"],
})
export class RadioComponent {
  form: FormGroup;
  inputFormCtrl = new FormControl("");
  radioFormCtrl = new FormControl("");
  chkbox = new FormControl();
  txtArea = new FormControl();
  colorDropdown = new FormControl();

  constructor(private fb: FormBuilder) {
    this.form = new FormGroup({
      inputFormCtrl: this.inputFormCtrl,
      radioFormCtrl: this.radioFormCtrl,
      chkbox: this.chkbox,
      txtArea: this.txtArea,
      colorDropdown: this.colorDropdown,
    });
  }

  onSubmit() {
    this.inputFormCtrl.setValidators([Validators.required]);
    this.inputFormCtrl.updateValueAndValidity();

    this.radioFormCtrl.setValidators([Validators.required]);
    this.radioFormCtrl.updateValueAndValidity();

    this.chkbox.setValidators([Validators.required]);
    this.chkbox.updateValueAndValidity();

    this.txtArea.setValidators([Validators.required]);
    this.txtArea.updateValueAndValidity();

    this.colorDropdown.setValidators([Validators.required]);
    this.colorDropdown.updateValueAndValidity();

    this.form.markAllAsTouched();

    if (this.form.valid) {
      console.log("Form is valid");
    }
  }
}
<form [formGroup]="form" style="margin-top: 100px;">
<goa-form-item
        label="Amount"
        requirement="required"
        helptext="Help Text: This is the amount you want to transfer."
        [error]="form.controls['inputFormCtrl'].invalid && form.controls['inputFormCtrl'].touched ? 'Error Message: You must enter an amount.' : null">

  <goa-input
          name="inputFormCtrl"
          goaValue
          width="398px"
          [formControl]="inputFormCtrl"
          [error]="form.controls['inputFormCtrl'].invalid && form.controls['inputFormCtrl'].touched"
  ></goa-input>
</goa-form-item>

<br>

<goa-form-item
    label="Accounts"
    mb="l"
    helptext="Help Text: Select an account"
    [error]="form.controls['radioFormCtrl'].invalid && form.controls['radioFormCtrl'].touched ? 'Error Message: You must select an account.' : null"
>
<goa-radio-group
    goaValue
    formControlName="radioFormCtrl"
    [error]="form.controls['radioFormCtrl'].invalid && form.controls['radioFormCtrl'].touched"
    >
  <goa-radio-item value="1" label="Account 1"></goa-radio-item>
  <goa-radio-item value="2" label="Account 2"></goa-radio-item>
  <goa-radio-item value="3" label="Account 3"></goa-radio-item>
</goa-radio-group>
</goa-form-item>

<br>

<goa-form-item
  label="Desserts"
  mb="l"
  helptext="Help Text: Select a dessert"
  [error]="form.controls['chkbox'].invalid && form.controls['chkbox'].touched ? 'Error Message: You must select the ice cream.' : null">
  <goa-checkbox
    name="desserts"
    text="Ice Cream"
    value="10"
    goaChecked
    [formControl]="chkbox"
    [error]="form.controls['chkbox'].invalid && form.controls['chkbox'].touched"
  >
</goa-checkbox>
</goa-form-item>


<br>
<goa-form-item
  label="Charges"
  [error]="form.controls['txtArea'].invalid && form.controls['txtArea'].touched ? 'Error Message: You must enter some details.' : null"
  helpText="Help Text: Enter the charges">
  <goa-textarea goaValue
      [formControl]="txtArea" width="944px" countby="character" maxcount="500" countby="character"
      [error]="form.controls['txtArea'].invalid && form.controls['txtArea'].touched" />
</goa-form-item>

<br>
<goa-form-item
  requirement="required"
  mt="l"
  label="Colors Dropdown"
  helpText="Help Text: Select a color from the dropdown list"
  [error]="form.controls['colorDropdown'].invalid && form.controls['colorDropdown'].touched ? 'Error Message: You must pick a color.' : null">
<goa-dropdown [formControl]="colorDropdown" goaValue name="item" value="" width="200px"
              [error]="form.controls['colorDropdown'].invalid && form.controls['colorDropdown'].touched">
  <goa-dropdown-item value="red" label="Red"></goa-dropdown-item>
  <goa-dropdown-item value="green" label="Green"></goa-dropdown-item>
  <goa-dropdown-item value="blue" label="Blue"></goa-dropdown-item>
</goa-dropdown>
</goa-form-item>

</form>
<br><br>
<goa-button (_click)="onSubmit()" type="primary">Submit</goa-button>

@syedszeeshan syedszeeshan changed the title NOT READY - fix(#2028): input formitem add accessibility features fix(#2028): input formitem add accessibility features Aug 12, 2024
@syedszeeshan syedszeeshan force-pushed the SZ-2028-UI branch 2 times, most recently from 4eba8d3 to 19abc89 Compare August 12, 2024 23:18
@ArakTaiRoth ArakTaiRoth linked an issue Aug 13, 2024 that may be closed by this pull request
@syedszeeshan syedszeeshan force-pushed the SZ-2028-UI branch 3 times, most recently from 3fa3fb4 to 171c970 Compare August 19, 2024 18:39
@lizhuomeng71
Copy link
Collaborator

lizhuomeng71 commented Oct 2, 2024

Helper Text and Error Text Was not read out by NVDA and Narrator

The Requirement of this ticket specified that help text and error text should be ready out, however, even aria-describedby="helptext-akr95iq" exist, NVDA and Narrator does not read it out

Code Example as such


<goa-form-item label="Input Label" requirement="required" labelsize="regular" helptext="This is Basic Helper Text" error="This is Basic Error Text">
  <goa-input width="20ch" error="true" name="item" [value]="value" (_change)="onChange($event)"></goa-input>
</goa-form-item>

@syedszeeshan syedszeeshan changed the title fix(#2028): input formitem add accessibility features DON REVIEW DONT TEST - fix(#2028): input formitem add accessibility features Oct 17, 2024
@syedszeeshan syedszeeshan changed the title DON REVIEW DONT TEST - fix(#2028): input formitem add accessibility features DONT REVIEW / TEST - fix(#2028): input formitem add accessibility features Oct 17, 2024
@syedszeeshan syedszeeshan force-pushed the SZ-2028-UI branch 2 times, most recently from 28d3cab to e89906a Compare October 28, 2024 20:14
@syedszeeshan
Copy link
Collaborator Author

2028-NVDA-ScreenReader-RegFlow.mp4

@syedszeeshan
Copy link
Collaborator Author

syedszeeshan commented Oct 28, 2024

2028-NVDA-ScreenReader-Validation.mp4

Video is showing that screen reader announces the 'error' as soon as the validation happens.

@syedszeeshan
Copy link
Collaborator Author

syedszeeshan commented Oct 28, 2024

2028-NVDA-ScreenReader-onFocus.mp4

As requested, when an input element is focused, the screen reader announces the helper text (note that there is no validation error yet).

NOTE: I have modified the outline to 1px solid red only for the video.... so that when the radiogroup is focused in using tab button, it is visible.

There is announcement when the Radio group is focused as well as when an individual radio item is focused. I can change if this is not the desired behavior.

@syedszeeshan
Copy link
Collaborator Author

syedszeeshan commented Oct 28, 2024

2028-NVDA-ScreenReader-onFocus-Validation.mp4

But when there is validation error, and an input element is focused, the screen reader announces the helper text error text.

NOTE: I have modified the outline to 1px solid red only for the video.... so that when the radiogroup is focused in using tab button, it is visible.

There is announcement when the Radio group is focused as well as when an individual radio item is focused. I can change if this is not the desired behavior.

@syedszeeshan syedszeeshan changed the title DONT REVIEW / TEST - fix(#2028): input formitem add accessibility features fix(#2028): input formitem add accessibility features Oct 28, 2024
@lizhuomeng71
Copy link
Collaborator

But when there is validation error, and an input element is focused, the screen reader announces the helper text error text.

For this case, the NVDA still announces the helper text in the audio (EVEN the print to screen show it announce the error text)

@lizhuomeng71 lizhuomeng71 marked this pull request as ready for review November 1, 2024 19:26
@syedszeeshan syedszeeshan changed the title fix(#2028): input formitem add accessibility features fix(#2028): add accessibility features Nov 5, 2024
vanessatran-ddi
vanessatran-ddi previously approved these changes Nov 5, 2024
@ArakTaiRoth ArakTaiRoth merged commit a3cd2a2 into GovAlta:alpha Nov 7, 2024
1 check passed
@tzuge
Copy link
Collaborator

tzuge commented Nov 7, 2024

🎉 This PR is included in version 1.17.0-alpha.121 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tzuge tzuge added the released on @alpha Released into alpha. label Nov 7, 2024
@tzuge
Copy link
Collaborator

tzuge commented Nov 27, 2024

🎉 This PR is included in version 5.0.0-alpha.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tzuge
Copy link
Collaborator

tzuge commented Dec 9, 2024

🎉 This PR is included in version 3.0.0-alpha.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @alpha Released into alpha.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Input: Various accessibility features
6 participants