Skip to content

Commit

Permalink
feat(accessibility): added missing <legend>-elements to form fields…
Browse files Browse the repository at this point in the history
…ets (#1694)
  • Loading branch information
LucasHengelhaupt committed Sep 4, 2024
1 parent 4a1620f commit e931783
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export class CostCenterFormComponent implements OnInit {
return [
{
type: 'ish-fieldset-field',
props: {
legend: 'account.costcenter.create.heading',
legendClass: 'legend-invisible',
},
fieldGroup: [
{
key: 'currency',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export class UserBudgetFormComponent implements OnInit {
return [
{
type: 'ish-fieldset-field',
props: {
legend: 'account.user.update_budget.heading',
legendClass: 'legend-invisible',
},
fieldGroup: [
{
key: 'currency',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class UserProfileFormComponent implements OnInit {
return [
{
type: 'ish-fieldset-field',
props: {
legend: 'account.register.personal_information.heading',
legendClass: 'legend-invisible',
},
fieldGroup: [
{
type: '#title',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<fieldset>
<legend class="legend-invisible">{{ 'account.user.details.profile.role_permissions.heading' | translate }}</legend>
<div class="row">
<div class="col-md-4 col-form-label">{{ 'account.user.details.profile.role_permissions.heading' | translate }}</div>
<div class="col-md-8">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ <h1>{{ 'store_locator.title' | translate }}</h1>
<form [formGroup]="form" (ngSubmit)="submitForm()">
<div class="row">
<fieldset class="col-sm-8">
<legend class="legend-invisible">{{ 'store_locator.title' | translate }}</legend>
<formly-form [form]="form" [fields]="fields" [model]="model" />
<div class="form-group row align-items-baseline">
<div class="col-sm-4"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export class RegistrationFormConfigurationService {
props: {
fieldsetClass: 'row',
childClass: 'col-md-10 col-lg-8 col-xl-6',
legend: 'account.register.address.headding',
legendClass: 'legend-invisible',
},
fieldGroup: [
{
Expand Down Expand Up @@ -237,6 +239,8 @@ export class RegistrationFormConfigurationService {
props: {
fieldsetClass: 'row',
childClass: 'col-md-10 col-lg-8 col-xl-6',
legend: 'account.register.email_password.heading',
legendClass: 'legend-invisible',
},
validators: {
validation: [
Expand Down Expand Up @@ -318,6 +322,8 @@ export class RegistrationFormConfigurationService {
props: {
fieldsetClass: 'row',
childClass: 'col-md-10 col-lg-8 col-xl-6',
legend: 'account.register.personal_information.heading',
legendClass: 'legend-invisible',
},
fieldGroup: this.fieldLibrary.getConfigurationGroup('personalInfo'),
},
Expand All @@ -339,6 +345,8 @@ export class RegistrationFormConfigurationService {
props: {
fieldsetClass: 'row',
childClass: 'col-md-10 col-lg-8 col-xl-6',
legend: 'account.register.company_information.heading',
legendClass: 'legend-invisible',
},
fieldGroup: this.fieldLibrary.getConfigurationGroup('companyInfo'),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<fieldset [ngClass]="props.fieldsetClass">
<legend *ngIf="props.legend" [ngClass]="props.legendClass">{{ props.legend | translate }}</legend>
<div [ngClass]="props.childClass">
<legend *ngIf="props.legend" [ngClass]="props.legendClass">{{ props.legend | translate }}</legend>
<formly-field *ngFor="let f of field.fieldGroup" [field]="f" />
</div>
</fieldset>
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('Fieldset Field Component', () => {

it('should contain a legend in a fieldset', () => {
fixture.detectChanges();
expect(element.querySelector('fieldset > div > legend')).toBeTruthy();
expect(element.querySelector('fieldset > legend')).toBeTruthy();
});

it('should contain a legend class in a fieldset', () => {
Expand Down
6 changes: 6 additions & 0 deletions src/styles/global/forms.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
// FIELDSET
fieldset {
margin-bottom: ($space-default);

legend {
font-size: $font-size-corporate;
}

.legend-invisible {
position: absolute;
left: -10000px;
}
}

// REQUIRED FIELDS
Expand Down

0 comments on commit e931783

Please sign in to comment.