Skip to content

Commit 9a5ad0b

Browse files
Fixed accessibility issues on search page
1 parent 5566c99 commit 9a5ad0b

6 files changed

Lines changed: 29 additions & 11 deletions

File tree

src/app/shared/object-collection/shared/selectable-list-item-control/selectable-list-item-control.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<ng-container *ngVar="selectionService?.isObjectSelected(selectionConfig?.listId, object) | async as checked">
2-
<input *ngIf="selectionConfig.repeatable" class="form-check-input" type="checkbox"
2+
<input #selectListItemCheckbox *ngIf="selectionConfig.repeatable" class="form-check-input" type="checkbox"
3+
[attr.aria-label]="(selectListItemCheckbox.checked ? 'selectable-list-item-control.deselect' : 'selectable-list-item-control.select') | translate"
34
[name]="'checkbox' + index"
45
[id]="'object' + index"
56
[ngModel]="selected$ | async"
67
(ngModelChange)="selectCheckbox($event)">
78
<input *ngIf="!selectionConfig.repeatable" class="form-check-input mt-2" type="radio"
9+
[attr.aria-label]="'selectable-list-item-control.select' | translate"
810
[name]="'radio' + index"
911
[id]="'object' + index"
1012
[checked]="selected$ | async"

src/app/shared/object-collection/shared/selectable-list-item-control/selectable-list-item-control.component.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { FormsModule } from '@angular/forms';
77
import { VarDirective } from '../../../utils/var.directive';
88
import { of as observableOf } from 'rxjs';
99
import { ListableObject } from '../listable-object.model';
10+
import { TranslateModule } from '@ngx-translate/core';
1011

1112
describe('SelectableListItemControlComponent', () => {
1213
let comp: SelectableListItemControlComponent;
@@ -45,7 +46,10 @@ describe('SelectableListItemControlComponent', () => {
4546
init();
4647
TestBed.configureTestingModule({
4748
declarations: [SelectableListItemControlComponent, VarDirective],
48-
imports: [FormsModule],
49+
imports: [
50+
FormsModule,
51+
TranslateModule.forRoot(),
52+
],
4953
providers: [
5054
{
5155
provide: SelectableListService,

src/app/shared/search/search-filters/search-filter/search-filter.component.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
[id]="regionId" [attr.aria-labelledby]="toggleId" [ngClass]="{ 'focus': focusBox }" role="region">
33
<button (click)="toggle()" (focusin)="focusBox = true" (focusout)="focusBox = false"
44
class="filter-name d-flex" [attr.aria-controls]="regionId" [id]="toggleId"
5-
[attr.aria-expanded]="false"
5+
[attr.aria-expanded]="!(collapsed$ | async)"
66
[attr.aria-label]="(((collapsed$ | async) ? 'search.filters.filter.expand' : 'search.filters.filter.collapse') | translate) + ' ' + (('search.filters.filter.' + filter.name + '.head') | translate | lowercase)"
77
[attr.data-test]="'filter-toggle' | dsBrowserOnly"
88
>
9-
<h4 class="d-inline-block text-left mt-auto mb-auto">
9+
<span class="h4 d-inline-block text-left mt-auto mb-auto">
1010
{{'search.filters.filter.' + filter.name + '.head'| translate}}
11-
</h4>
12-
<span class="filter-toggle flex-grow-1 fas p-auto"
13-
[ngClass]="(collapsed$ | async) ? 'fa-plus' : 'fa-minus'"
14-
[title]="((collapsed$ | async) ? 'search.filters.filter.expand' : 'search.filters.filter.collapse') | translate">
1511
</span>
12+
<i class="filter-toggle flex-grow-1 fas p-auto"
13+
aria-hidden="true"
14+
[ngClass]="(collapsed$ | async) ? 'fa-plus' : 'fa-minus'"
15+
[title]="((collapsed$ | async) ? 'search.filters.filter.expand' : 'search.filters.filter.collapse') | translate">
16+
</i>
1617
</button>
1718
<div [@slide]="(collapsed$ | async) ? 'collapsed' : 'expanded'"
1819
(@slide.start)="startSlide($event)" (@slide.done)="finishSlide($event)"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<a class="badge badge-primary mr-1 mb-1"
2+
[attr.aria-label]="'search.filters.remove' | translate:{ type: ('search.filters.applied.' + key) | translate, value: normalizeFilterValue(value) }"
23
[routerLink]="searchLink"
34
[queryParams]="(removeParameters | async)" queryParamsHandling="merge">
45
{{('search.filters.applied.' + key) | translate}}: {{'search.filters.' + filterName + '.' + value | translate: {default: normalizeFilterValue(value)} }}
5-
<span> ×</span>
6+
<span aria-hidden="true"> ×</span>
67
</a>

src/app/shared/view-mode-switch/view-mode-switch.component.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<div class="btn-group" data-toggle="buttons">
22
<button *ngIf="isToShow(viewModeEnum.ListElement)"
3+
[attr.aria-current]="currentMode === viewModeEnum.ListElement"
4+
[attr.aria-label]="'search.view-switch.show-list' | translate"
35
routerLink="."
46
[queryParams]="{view: 'list'}"
57
queryParamsHandling="merge"
@@ -8,9 +10,11 @@
810
[class.active]="currentMode === viewModeEnum.ListElement"
911
class="btn btn-secondary"
1012
[attr.data-test]="'list-view' | dsBrowserOnly">
11-
<span class="fas fa-list"></span><span class="sr-only">{{'search.view-switch.show-list' | translate}}</span>
13+
<i class="fas fa-list"></i>
1214
</button>
1315
<button *ngIf="isToShow(viewModeEnum.GridElement)"
16+
[attr.aria-current]="currentMode === viewModeEnum.GridElement"
17+
[attr.aria-label]="'search.view-switch.show-grid' | translate"
1418
routerLink="."
1519
[queryParams]="{view: 'grid'}"
1620
queryParamsHandling="merge"
@@ -19,7 +23,7 @@
1923
[class.active]="currentMode === viewModeEnum.GridElement"
2024
class="btn btn-secondary"
2125
[attr.data-test]="'grid-view' | dsBrowserOnly">
22-
<span class="fas fa-th-large"></span><span class="sr-only">{{'search.view-switch.show-grid' | translate}}</span>
26+
<i class="fas fa-th-large"></i>
2327
</button>
2428
<button *ngIf="isToShow(viewModeEnum.DetailedListElement)"
2529
routerLink="."

src/assets/i18n/en.json5

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3666,6 +3666,8 @@
36663666

36673667
"search.search-form.placeholder": "Search the repository ...",
36683668

3669+
"search.filters.remove": "Remove filter of type {{ type }} with value {{ value }}",
3670+
36693671
"search.filters.applied.f.author": "Author",
36703672

36713673
"search.filters.applied.f.dateIssued.max": "End date",
@@ -3920,6 +3922,10 @@
39203922

39213923
"search.view-switch.show-list": "Show as list",
39223924

3925+
"selectable-list-item-control.deselect": "Deselect item",
3926+
3927+
"selectable-list-item-control.select": "Select item",
3928+
39233929
"sorting.ASC": "Ascending",
39243930

39253931
"sorting.DESC": "Descending",

0 commit comments

Comments
 (0)