Skip to content

Commit

Permalink
feat: add aria-label property to formly components
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasHengelhaupt authored and SGrueber committed Aug 29, 2023
1 parent cfe40ff commit d60c051
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/guides/formly.md
Expand Up @@ -251,7 +251,8 @@ Refer to the tables below for an overview of these parts.

### Field Types

Template option `inputClass`: These css class(es) will be added to all input/select/textarea/text tags.
- Template option `inputClass`: These CSS class(es) will be added to all input/select/textarea/text tags.
- Template option `ariaLabel`: Adds an aria-label to all input/select/textarea tags.

| Name | Description | Relevant props |
| -------------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
Expand Up @@ -5,4 +5,5 @@
class="form-check-input"
[ngClass]="props.inputClass"
[attr.data-testing-id]="field.key"
[attr.aria-label]="props.ariaLabel"
/>
Expand Up @@ -4,6 +4,8 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
/**
* Type for a basic checkbox field.
*
* @props **ariaLabel** adds an aria-label to the component for better accessibility, recommended if there is no associated label
*
* @defaultWrappers form-field-checkbox-horizontal
*
* @usageNotes
Expand Down
Expand Up @@ -7,4 +7,5 @@
class="form-check-input"
[ngClass]="props.inputClass"
[attr.data-testing-id]="'radio-' + props.label"
[attr.aria-label]="props.ariaLabel"
/>
Expand Up @@ -4,6 +4,7 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
/**
* Basic type for radio buttons
*
* @props **ariaLabel** adds an aria-label to the component for better accessibility, recommended if there is no associated label
* @props **label** - the text that should be shown next to the radio button
* @props **value** - the value that should be associated with this radio button
*
Expand Down
Expand Up @@ -5,6 +5,7 @@
class="form-control"
[ngClass]="props.inputClass"
[attr.data-testing-id]="field.key"
[attr.aria-label]="props.ariaLabel"
>
<ng-container *ngIf="selectOptions && selectOptions | formlySelectOptions : field | async as opts">
<ng-container *ngFor="let opt of opts">
Expand Down
Expand Up @@ -5,4 +5,5 @@
class="form-control"
[ngClass]="props.inputClass"
[attr.data-testing-id]="field.key"
[attr.aria-label]="props.ariaLabel"
/>
Expand Up @@ -4,6 +4,7 @@ import { FieldType, FieldTypeConfig, FormlyFieldConfig } from '@ngx-formly/core'
/**
* Type for a basic input field
*
* @props **ariaLabel** adds an aria-label to the component for better accessibility, recommended if there is no associated label
* @props **type** supports all text types; 'text' (default), 'email', 'password', 'tel'
*
* @defaultWrappers form-field-horizontal & validation
Expand Down
Expand Up @@ -6,4 +6,5 @@
class="form-control"
[ngClass]="props.inputClass"
[attr.data-testing-id]="field.key"
[attr.aria-label]="props.ariaLabel"
></textarea>
Expand Up @@ -4,6 +4,7 @@ import { FieldType, FieldTypeConfig } from '@ngx-formly/core';
/**
* Type for a basic textarea field
*
* @props **ariaLabel** adds an aria-label to the component for better accessibility, recommended if there is no associated label
* @props **cols** - the amount of columns the textarea should have
* @props **rows** - the amount of rows the textarea should have
*
Expand Down

0 comments on commit d60c051

Please sign in to comment.