Skip to content

Commit 9e29cfb

Browse files
Fixed user authentication/registration accessibility issue
- Added the correct autocomplete value - Removed dangling labels, because aria labels already describe those input fields & we can't use ids in this component because otherwise there are duplicate ids on the /login page
1 parent e36bf64 commit 9e29cfb

7 files changed

Lines changed: 26 additions & 20 deletions

File tree

src/app/forgot-password/forgot-password-form/forgot-password-form.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<div class="container" *ngIf="(registration$ |async)">
2-
<h3 class="mb-4">{{'forgot-password.form.head' | translate}}</h3>
2+
<h1 class="mb-4">{{'forgot-password.form.head' | translate}}</h1>
33
<div class="card mb-4">
44
<div class="card-header">{{'forgot-password.form.identification.header' | translate}}</div>
55
<div class="card-body">
66
<div class="row">
77
<div class="col-12">
8-
<label class="font-weight-bold"
9-
for="email">{{'forgot-password.form.identification.email' | translate}}</label>
10-
<span id="email">{{(registration$ |async).email}}</span></div>
8+
<span class="font-weight-bold">{{'forgot-password.form.identification.email' | translate}} </span>
9+
<span [attr.data-test]="'email' | dsBrowserOnly">{{(registration$ |async).email}}</span>
10+
</div>
1111
</div>
1212
</div>
1313
</div>

src/app/forgot-password/forgot-password-form/forgot-password-form.component.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
createSuccessfulRemoteDataObject$
2222
} from '../../shared/remote-data.utils';
2323
import { CoreState } from '../../core/core-state.model';
24+
import { BrowserOnlyPipe } from '../../shared/utils/browser-only.pipe';
2425

2526
describe('ForgotPasswordFormComponent', () => {
2627
let comp: ForgotPasswordFormComponent;
@@ -54,7 +55,10 @@ describe('ForgotPasswordFormComponent', () => {
5455

5556
TestBed.configureTestingModule({
5657
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), ReactiveFormsModule],
57-
declarations: [ForgotPasswordFormComponent],
58+
declarations: [
59+
BrowserOnlyPipe,
60+
ForgotPasswordFormComponent,
61+
],
5862
providers: [
5963
{provide: Router, useValue: router},
6064
{provide: ActivatedRoute, useValue: route},
@@ -75,7 +79,7 @@ describe('ForgotPasswordFormComponent', () => {
7579

7680
describe('init', () => {
7781
it('should initialise mail address', () => {
78-
const elem = fixture.debugElement.queryAll(By.css('span#email'))[0].nativeElement;
82+
const elem = fixture.debugElement.queryAll(By.css('span[data-test="email"]'))[0].nativeElement;
7983
expect(elem.innerHTML).toContain('test@email.org');
8084
});
8185
});

src/app/profile-page/profile-page-metadata-form/profile-page-metadata-form.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export class ProfilePageMetadataFormComponent implements OnInit {
4343
new DynamicInputModel({
4444
id: 'email',
4545
name: 'email',
46-
readOnly: true
46+
readOnly: true,
47+
disabled: true,
4748
}),
4849
new DynamicInputModel({
4950
id: 'firstname',
@@ -55,6 +56,7 @@ export class ProfilePageMetadataFormComponent implements OnInit {
5556
errorMessages: {
5657
required: 'This field is required'
5758
},
59+
autoComplete: 'given-name',
5860
}),
5961
new DynamicInputModel({
6062
id: 'lastname',
@@ -66,10 +68,12 @@ export class ProfilePageMetadataFormComponent implements OnInit {
6668
errorMessages: {
6769
required: 'This field is required'
6870
},
71+
autoComplete: 'family-name',
6972
}),
7073
new DynamicInputModel({
7174
id: 'phone',
72-
name: 'eperson.phone'
75+
name: 'eperson.phone',
76+
autoComplete: 'tel',
7377
}),
7478
new DynamicSelectModel<string>({
7579
id: 'language',

src/app/profile-page/profile-page-security-form/profile-page-security-form.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ export class ProfilePageSecurityFormComponent implements OnInit {
3939
new DynamicInputModel({
4040
id: 'password',
4141
name: 'password',
42-
inputType: 'password'
42+
inputType: 'password',
43+
autoComplete: 'new-password',
4344
}),
4445
new DynamicInputModel({
4546
id: 'passwordrepeat',
4647
name: 'passwordrepeat',
47-
inputType: 'password'
48+
inputType: 'password',
49+
autoComplete: 'new-password',
4850
})
4951
];
5052

@@ -79,7 +81,8 @@ export class ProfilePageSecurityFormComponent implements OnInit {
7981
id: 'current-password',
8082
name: 'current-password',
8183
inputType: 'password',
82-
required: true
84+
required: true,
85+
autoComplete: 'current-password',
8386
}));
8487
}
8588
if (this.passwordCanBeEmpty) {

src/app/profile-page/profile-page.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<ng-container *ngVar="(user$ | async) as user">
22
<div class="container" *ngIf="user">
33
<h1>{{'profile.title' | translate}}</h1>
4-
<ng-container *ngIf="isResearcherProfileEnabled() | async">
5-
<h2 class="mb-4">{{'profile.head' | translate}}</h2>
4+
<ng-container>
65
<div class="card mb-4">
76
<div class="card-header">{{'profile.card.researcher' | translate}}</div>
87
<div class="card-body">

src/app/shared/log-in/methods/password/log-in-password.component.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<form class="form-login"
22
(ngSubmit)="submit()"
33
[formGroup]="form" novalidate>
4-
<label class="sr-only">{{"login.form.email" | translate}}</label>
54
<input [attr.aria-label]="'login.form.email' |translate"
6-
autocomplete="off"
5+
autocomplete="username"
76
autofocus
87
class="form-control form-control-lg position-relative"
98
formControlName="email"
109
placeholder="{{'login.form.email' | translate}}"
1110
required
1211
type="email"
1312
[attr.data-test]="'email' | dsBrowserOnly">
14-
<label class="sr-only">{{"login.form.password" | translate}}</label>
1513
<input [attr.aria-label]="'login.form.password' |translate"
16-
autocomplete="off"
14+
autocomplete="current-password"
1715
class="form-control form-control-lg position-relative mb-3"
1816
placeholder="{{'login.form.password' | translate}}"
1917
formControlName="password"

src/assets/i18n/en.json5

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@
17201720

17211721
"forgot-password.form.label.passwordrepeat": "Retype to confirm",
17221722

1723-
"forgot-password.form.error.empty-password": "Please enter a password in the box below.",
1723+
"forgot-password.form.error.empty-password": "Please enter a password in the boxes above.",
17241724

17251725
"forgot-password.form.error.matching-passwords": "The passwords do not match.",
17261726

@@ -3490,8 +3490,6 @@
34903490

34913491
"profile.special.groups.head": "Authorization special groups you belong to",
34923492

3493-
"profile.head": "Update Profile",
3494-
34953493
"profile.metadata.form.error.firstname.required": "First Name is required",
34963494

34973495
"profile.metadata.form.error.lastname.required": "Last Name is required",

0 commit comments

Comments
 (0)