Skip to content

Commit b2a1553

Browse files
author
Jens Vannerum
committed
Merge branch 'w2p-117544_support-for-disabled-elements-for-screen-readers-7.6' into w2p-117544_support-for-disabled-elements-for-screen-readers-8.0
2 parents 3e6adbb + 2d48cc0 commit b2a1553

61 files changed

Lines changed: 328 additions & 122 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/app/access-control/bulk-access/bulk-access.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h1>{{ 'admin.access-control.bulk-access.title' | translate }}</h1>
1010
<button class="btn btn-outline-primary mr-3" (click)="reset()">
1111
{{ 'access-control-cancel' | translate }}
1212
</button>
13-
<button class="btn btn-primary" [disabled]="!canExport()" (click)="submit()">
13+
<button class="btn btn-primary" [dsDisabled]="!canExport()" (click)="submit()">
1414
{{ 'access-control-execute' | translate }}
1515
</button>
1616
</div>

src/app/access-control/epeople-registry/epeople-registry.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { NotificationsServiceStub } from '../../shared/testing/notifications-ser
5757
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
5858
import { EPeopleRegistryComponent } from './epeople-registry.component';
5959
import { EPersonFormComponent } from './eperson-form/eperson-form.component';
60+
import {DisabledDirective} from '../../shared/disabled-directive';
6061

6162
describe('EPeopleRegistryComponent', () => {
6263
let component: EPeopleRegistryComponent;
@@ -151,7 +152,7 @@ describe('EPeopleRegistryComponent', () => {
151152
paginationService = new PaginationServiceStub();
152153
TestBed.configureTestingModule({
153154
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule, RouterTestingModule.withRoutes([]),
154-
TranslateModule.forRoot(), EPeopleRegistryComponent],
155+
TranslateModule.forRoot(), EPeopleRegistryComponent, DisabledDirective],
155156
providers: [
156157
{ provide: EPersonDataService, useValue: ePersonDataServiceStub },
157158
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },

src/app/access-control/epeople-registry/eperson-form/eperson-form.component.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import { HasNoValuePipe } from '../../../shared/utils/has-no-value.pipe';
6868
import { EPeopleRegistryComponent } from '../epeople-registry.component';
6969
import { EPersonFormComponent } from './eperson-form.component';
7070
import { ValidateEmailNotTaken } from './validators/email-taken.validator';
71+
import {DisabledDirective} from '../../../shared/disabled-directive';
7172

7273
describe('EPersonFormComponent', () => {
7374
let component: EPersonFormComponent;
@@ -227,7 +228,7 @@ describe('EPersonFormComponent', () => {
227228
route = new ActivatedRouteStub();
228229
router = new RouterStub();
229230
TestBed.configureTestingModule({
230-
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
231+
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, DisabledDirective, BrowserModule,
231232
TranslateModule.forRoot({
232233
loader: {
233234
provide: TranslateLoader,
@@ -546,7 +547,8 @@ describe('EPersonFormComponent', () => {
546547
// ePersonDataServiceStub.activeEPerson = eperson;
547548
spyOn(component.epersonService, 'deleteEPerson').and.returnValue(createSuccessfulRemoteDataObject$('No Content', 204));
548549
const deleteButton = fixture.debugElement.query(By.css('.delete-button'));
549-
expect(deleteButton.nativeElement.disabled).toBe(false);
550+
expect(deleteButton.nativeElement.getAttribute('aria-disabled')).toBe('false');
551+
expect(deleteButton.nativeElement.classList.contains('disabled')).toBeFalse();
550552
deleteButton.triggerEventHandler('click', null);
551553
fixture.detectChanges();
552554
expect(component.epersonService.deleteEPerson).toHaveBeenCalledWith(eperson);

src/app/access-control/group-registry/groups-registry.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ <h2 id="search" class="border-bottom pb-2">{{messagePrefix + 'search.head' | tra
6969
<i class="fas fa-edit fa-fw"></i>
7070
</button>
7171
<button *ngSwitchCase="false"
72-
[disabled]="true"
72+
[dsDisabled]="true"
7373
class="btn btn-outline-primary btn-sm btn-edit"
7474
placement="left"
7575
[ngbTooltip]="'admin.access-control.epeople.table.edit.buttons.edit-disabled' | translate"

src/app/access-control/group-registry/groups-registry.component.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import { NotificationsServiceStub } from '../../shared/testing/notifications-ser
7171
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
7272
import { routeServiceStub } from '../../shared/testing/route-service.stub';
7373
import { GroupsRegistryComponent } from './groups-registry.component';
74+
import {DisabledDirective} from '../../shared/disabled-directive';
7475

7576
describe('GroupsRegistryComponent', () => {
7677
let component: GroupsRegistryComponent;
@@ -208,6 +209,7 @@ describe('GroupsRegistryComponent', () => {
208209
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
209210
TranslateModule.forRoot(),
210211
GroupsRegistryComponent,
212+
DisabledDirective
211213
],
212214
providers: [GroupsRegistryComponent,
213215
{ provide: DSONameService, useValue: new DSONameServiceMock() },
@@ -278,7 +280,8 @@ describe('GroupsRegistryComponent', () => {
278280
const editButtonsFound = fixture.debugElement.queryAll(By.css('#groups tr td:nth-child(5) button.btn-edit'));
279281
expect(editButtonsFound.length).toEqual(2);
280282
editButtonsFound.forEach((editButtonFound) => {
281-
expect(editButtonFound.nativeElement.disabled).toBeFalse();
283+
expect(editButtonFound.nativeElement.getAttribute('aria-disabled')).toBeNull();
284+
expect(editButtonFound.nativeElement.classList.contains('disabled')).toBeFalse();
282285
});
283286
});
284287

@@ -312,7 +315,8 @@ describe('GroupsRegistryComponent', () => {
312315
const editButtonsFound = fixture.debugElement.queryAll(By.css('#groups tr td:nth-child(5) button.btn-edit'));
313316
expect(editButtonsFound.length).toEqual(2);
314317
editButtonsFound.forEach((editButtonFound) => {
315-
expect(editButtonFound.nativeElement.disabled).toBeFalse();
318+
expect(editButtonFound.nativeElement.getAttribute('aria-disabled')).toBeNull();
319+
expect(editButtonFound.nativeElement.classList.contains('disabled')).toBeFalse();
316320
});
317321
});
318322
});
@@ -331,7 +335,8 @@ describe('GroupsRegistryComponent', () => {
331335
const editButtonsFound = fixture.debugElement.queryAll(By.css('#groups tr td:nth-child(5) button.btn-edit'));
332336
expect(editButtonsFound.length).toEqual(2);
333337
editButtonsFound.forEach((editButtonFound) => {
334-
expect(editButtonFound.nativeElement.disabled).toBeTrue();
338+
expect(editButtonFound.nativeElement.getAttribute('aria-disabled')).toBe('true');
339+
expect(editButtonFound.nativeElement.classList.contains('disabled')).toBeTrue();
335340
});
336341
});
337342
});

src/app/collection-page/delete-collection-page/delete-collection-page.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ <h1 id="header" class="border-bottom pb-2">{{ 'collection.delete.head' | transla
66
<p class="pb-2">{{ 'collection.delete.text' | translate:{ dso: dsoNameService.getName(dso) } }}</p>
77
<div class="form-group row">
88
<div class="col text-right space-children-mr">
9-
<button class="btn btn-outline-secondary" (click)="onCancel(dso)" [disabled]="(processing$ | async)">
9+
<button class="btn btn-outline-secondary" (click)="onCancel(dso)" [dsDisabled]="(processing$ | async)">
1010
<i class="fas fa-times"></i> {{'collection.delete.cancel' | translate}}
1111
</button>
12-
<button class="btn btn-danger" (click)="onConfirm(dso)" [disabled]="(processing$ | async)">
12+
<button class="btn btn-danger" (click)="onConfirm(dso)" [dsDisabled]="(processing$ | async)">
1313
<span *ngIf="processing$ | async"><i class='fas fa-circle-notch fa-spin'></i> {{'collection.delete.processing' | translate}}</span>
1414
<span *ngIf="(processing$ | async) !== true"><i class="fas fa-trash"></i> {{'collection.delete.confirm' | translate}}</span>
1515
</button>

src/app/collection-page/edit-collection-page/collection-source/collection-source-controls/collection-source-controls.component.spec.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { createSuccessfulRemoteDataObject$ } from '../../../../shared/remote-dat
2727
import { NotificationsServiceStub } from '../../../../shared/testing/notifications-service.stub';
2828
import { VarDirective } from '../../../../shared/utils/var.directive';
2929
import { CollectionSourceControlsComponent } from './collection-source-controls.component';
30+
import {DisabledDirective} from '../../../../shared/disabled-directive';
3031

3132
describe('CollectionSourceControlsComponent', () => {
3233
let comp: CollectionSourceControlsComponent;
@@ -104,7 +105,7 @@ describe('CollectionSourceControlsComponent', () => {
104105
requestService = jasmine.createSpyObj('requestService', ['removeByHrefSubstring', 'setStaleByHrefSubstring']);
105106

106107
TestBed.configureTestingModule({
107-
imports: [TranslateModule.forRoot(), RouterTestingModule, CollectionSourceControlsComponent, VarDirective],
108+
imports: [TranslateModule.forRoot(), RouterTestingModule, CollectionSourceControlsComponent, VarDirective, DisabledDirective],
108109
providers: [
109110
{ provide: ScriptDataService, useValue: scriptDataService },
110111
{ provide: ProcessDataService, useValue: processDataService },
@@ -193,9 +194,11 @@ describe('CollectionSourceControlsComponent', () => {
193194

194195
const buttons = fixture.debugElement.queryAll(By.css('button'));
195196

196-
expect(buttons[0].nativeElement.disabled).toBeTrue();
197-
expect(buttons[1].nativeElement.disabled).toBeTrue();
198-
expect(buttons[2].nativeElement.disabled).toBeTrue();
197+
buttons.forEach(button => {
198+
console.log(button.nativeElement);
199+
expect(button.nativeElement.getAttribute('aria-disabled')).toBe('true');
200+
expect(button.nativeElement.classList.contains('disabled')).toBeTrue();
201+
});
199202
});
200203
it('should be enabled when isEnabled is true', () => {
201204
comp.shouldShow = true;
@@ -205,9 +208,10 @@ describe('CollectionSourceControlsComponent', () => {
205208

206209
const buttons = fixture.debugElement.queryAll(By.css('button'));
207210

208-
expect(buttons[0].nativeElement.disabled).toBeFalse();
209-
expect(buttons[1].nativeElement.disabled).toBeFalse();
210-
expect(buttons[2].nativeElement.disabled).toBeFalse();
211+
buttons.forEach(button => {
212+
expect(button.nativeElement.getAttribute('aria-disabled')).toBe('false');
213+
expect(button.nativeElement.classList.contains('disabled')).toBeFalse();
214+
});
211215
});
212216
it('should call the corresponding button when clicked', () => {
213217
spyOn(comp, 'testConfiguration');

src/app/dso-shared/dso-edit-metadata/dso-edit-metadata-value/dso-edit-metadata-value.component.spec.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
DsoEditMetadataValue,
4545
} from '../dso-edit-metadata-form';
4646
import { DsoEditMetadataValueComponent } from './dso-edit-metadata-value.component';
47+
import {DisabledDirective} from '../../../shared/disabled-directive';
4748

4849
const EDIT_BTN = 'edit';
4950
const CONFIRM_BTN = 'confirm';
@@ -188,6 +189,7 @@ describe('DsoEditMetadataValueComponent', () => {
188189
RouterTestingModule.withRoutes([]),
189190
DsoEditMetadataValueComponent,
190191
VarDirective,
192+
DisabledDirective
191193
],
192194
providers: [
193195
{ provide: RelationshipDataService, useValue: relationshipService },
@@ -524,7 +526,14 @@ describe('DsoEditMetadataValueComponent', () => {
524526
});
525527

526528
it(`should${disabled ? ' ' : ' not '}be disabled`, () => {
527-
expect(btn.nativeElement.disabled).toBe(disabled);
529+
if (disabled) {
530+
expect(btn.nativeElement.getAttribute('aria-disabled')).toBe('true');
531+
expect(btn.nativeElement.classList.contains('disabled')).toBeTrue();
532+
} else {
533+
// Can be null or false, depending on if button was ever disabled so just check not true
534+
expect(btn.nativeElement.getAttribute('aria-disabled')).not.toBe('true');
535+
expect(btn.nativeElement.classList.contains('disabled')).toBeFalse();
536+
}
528537
});
529538
} else {
530539
it('should not exist', () => {

src/app/dso-shared/dso-edit-metadata/dso-edit-metadata.component.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { DsoEditMetadataHeadersComponent } from './dso-edit-metadata-headers/dso
3232
import { DsoEditMetadataValueComponent } from './dso-edit-metadata-value/dso-edit-metadata-value.component';
3333
import { DsoEditMetadataValueHeadersComponent } from './dso-edit-metadata-value-headers/dso-edit-metadata-value-headers.component';
3434
import { MetadataFieldSelectorComponent } from './metadata-field-selector/metadata-field-selector.component';
35+
import {DisabledDirective} from '../../shared/disabled-directive';
3536

3637
const ADD_BTN = 'add';
3738
const REINSTATE_BTN = 'reinstate';
@@ -87,6 +88,7 @@ describe('DsoEditMetadataComponent', () => {
8788
]);
8889

8990
TestBed.configureTestingModule({
91+
declarations: [DisabledDirective]
9092
imports: [
9193
CommonModule,
9294
BrowserModule,
@@ -216,7 +218,13 @@ describe('DsoEditMetadataComponent', () => {
216218
});
217219

218220
it(`should${disabled ? ' ' : ' not '}be disabled`, () => {
219-
expect(btn.nativeElement.disabled).toBe(disabled);
221+
if (disabled) {
222+
expect(btn.nativeElement.getAttribute('aria-disabled')).toBe('true');
223+
expect(btn.nativeElement.classList.contains('disabled')).toBeTrue();
224+
} else {
225+
expect(btn.nativeElement.getAttribute('aria-disabled')).not.toBe('true');
226+
expect(btn.nativeElement.classList.contains('disabled')).toBeFalse();
227+
}
220228
});
221229
} else {
222230
it('should not exist', () => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1 class="mb-4">{{'forgot-password.form.head' | translate}}</h1>
2828
<div class="row">
2929
<div class="col-12">
3030
<button
31-
[disabled]="isInValid"
31+
[dsDisabled]="isInValid"
3232
class="btn btn-default btn-primary"
3333
(click)="submit()">{{'forgot-password.form.submit' | translate}}</button>
3434
</div>

0 commit comments

Comments
 (0)