Skip to content

Commit fa1ce5b

Browse files
authored
Merge pull request #3767 from DSpace/backport-3367-to-dspace-8_x
[Port dspace-8_x] Accessibility in vocabulary treeview
2 parents 60ff9a9 + 5d410b7 commit fa1ce5b

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

src/app/shared/form/vocabulary-treeview/vocabulary-treeview.component.html

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@
22
<div class="treeview-header row mb-1">
33
<div class="col-12">
44
<div class="input-group">
5-
<input type="text" class="form-control" [(ngModel)]="searchText" (keyup.enter)="search()"
5+
<input #searchInput type="text" class="form-control" [(ngModel)]="searchText" (keyup.enter)="search()"
66
[attr.aria-label]="'vocabulary-treeview.search.form.search-placeholder' | translate"
77
[placeholder]="'vocabulary-treeview.search.form.search-placeholder' | translate">
88
<div class="input-group-append" id="button-addon4">
9-
<button class="btn btn-outline-primary" type="button" (click)="search()" [disabled]="!isSearchEnabled()">
9+
<button class="btn btn-outline-primary" type="button" (click)="search()" [disabled]="!isSearchEnabled()"
10+
[attr.aria-label]="'vocabulary-treeview.search.form.search' | translate">
1011
{{'vocabulary-treeview.search.form.search' | translate}}
1112
</button>
12-
<button class="btn btn-outline-secondary" type="button" (click)="reset()">
13+
<button class="btn btn-outline-secondary" type="button" (click)="reset()"
14+
[attr.aria-label]="'vocabulary-treeview.search.form.reset' | translate">
1315
{{'vocabulary-treeview.search.form.reset' | translate}}
1416
</button>
15-
<button *ngIf="showAdd && this.vocabularyOptions.closed" class="btn btn-outline-primary" type="button" (click)="add()">
17+
<button *ngIf="showAdd && this.vocabularyOptions.closed" class="btn btn-outline-primary" type="button" (click)="add()"
18+
[attr.aria-label]="'vocabulary-treeview.search.form.add' | translate">
1619
{{'vocabulary-treeview.search.form.add' | translate}}
1720
</button>
18-
<button class="btn btn-outline-primary" type="button" (click)="add()" [disabled]="this.vocabularyOptions.closed">
21+
<button class="btn btn-outline-primary" type="button" (click)="add()" [disabled]="this.vocabularyOptions.closed"
22+
[attr.aria-label]="'vocabulary-treeview.search.form.add' | translate">
1923
{{'vocabulary-treeview.search.form.add' | translate}}
2024
</button>
2125
</div>
@@ -24,9 +28,11 @@
2428
</div>
2529
<div class="treeview-container">
2630
<ds-loading *ngIf="loading | async" [showMessage]="false"></ds-loading>
27-
<h2 *ngIf="(loading | async) !== true && dataSource.data.length === 0" class="h4 text-center text-muted mt-4" >
28-
<span>{{'vocabulary-treeview.search.no-result' | translate}}</span>
29-
</h2>
31+
<div aria-live="polite">
32+
<h2 *ngIf="(loading | async) !== true && dataSource.data.length === 0" class="h4 text-center text-muted mt-4" >
33+
<span>{{'vocabulary-treeview.search.no-result' | translate}}</span>
34+
</h2>
35+
</div>
3036
<cdk-tree [dataSource]="dataSource" [treeControl]="treeControl">
3137
<!-- Leaf node -->
3238
<cdk-tree-node *cdkTreeNodeDef="let node" cdkTreeNodePadding class="d-flex">
@@ -91,13 +97,15 @@ <h2 *ngIf="(loading | async) !== true && dataSource.data.length === 0" class="h4
9197
</cdk-tree-node>
9298

9399
<cdk-tree-node *cdkTreeNodeDef="let node; when: isLoadMore" cdkTreeNodePadding>
94-
<button class="btn btn-outline-secondary btn-sm" (click)="loadMore(node.loadMoreParentItem)">
100+
<button class="btn btn-outline-secondary btn-sm" (click)="loadMore(node.loadMoreParentItem)"
101+
[attr.aria-label]="'vocabulary-treeview.load-more' | translate">
95102
{{'vocabulary-treeview.load-more' | translate}}...
96103
</button>
97104
</cdk-tree-node>
98105

99106
<cdk-tree-node *cdkTreeNodeDef="let node; when: isLoadMoreRoot">
100-
<button class="btn btn-outline-secondary btn-sm" (click)="loadMoreRoot(node)">
107+
<button class="btn btn-outline-secondary btn-sm" (click)="loadMoreRoot(node)"
108+
[attr.aria-label]="'vocabulary-treeview.load-more' | translate">
101109
{{'vocabulary-treeview.load-more' | translate}}...
102110
</button>
103111
</cdk-tree-node>

src/app/shared/form/vocabulary-treeview/vocabulary-treeview.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import {
88
} from '@angular/common';
99
import {
1010
Component,
11+
ElementRef,
1112
EventEmitter,
1213
Input,
1314
OnChanges,
1415
OnDestroy,
1516
OnInit,
1617
Output,
1718
SimpleChanges,
19+
ViewChild,
1820
} from '@angular/core';
1921
import { FormsModule } from '@angular/forms';
2022
import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap';
@@ -70,6 +72,11 @@ export type VocabularyTreeItemType = FormFieldMetadataValueObject | VocabularyEn
7072
})
7173
export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges {
7274

75+
/**
76+
* Implemented to manage focus on input
77+
*/
78+
@ViewChild('searchInput') searchInput!: ElementRef;
79+
7380
/**
7481
* The {@link VocabularyOptions} object
7582
*/
@@ -332,6 +339,9 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges
332339
this.storedNodeMap = new Map<string, TreeviewFlatNode>();
333340
this.vocabularyTreeviewService.restoreNodes();
334341
}
342+
if (this.searchInput) {
343+
this.searchInput.nativeElement.focus();
344+
}
335345
}
336346

337347
add() {

0 commit comments

Comments
 (0)