Skip to content

Commit a8e658a

Browse files
authored
Merge pull request #3768 from tdonohue/port_3367_to_7x
[Port dspace-7_x] Accessibility in vocabulary treeview
2 parents 8152258 + a8ff6a4 commit a8e658a

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
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 class="btn btn-outline-primary" type="button" (click)="add()" [disabled]="this.vocabularyOptions.closed">
17+
<button class="btn btn-outline-primary" type="button" (click)="add()" [disabled]="this.vocabularyOptions.closed"
18+
[attr.aria-label]="'vocabulary-treeview.search.form.add' | translate">
1619
{{'vocabulary-treeview.search.form.add' | translate}}
1720
</button>
1821
</div>
@@ -21,9 +24,11 @@
2124
</div>
2225
<div class="treeview-container">
2326
<ds-themed-loading *ngIf="loading | async" [showMessage]="false"></ds-themed-loading>
24-
<h2 *ngIf="!(loading | async) && dataSource.data.length === 0" class="h4 text-center text-muted mt-4" >
25-
<span>{{'vocabulary-treeview.search.no-result' | translate}}</span>
26-
</h2>
27+
<div aria-live="polite">
28+
<h2 *ngIf="!(loading | async) && dataSource.data.length === 0" class="h4 text-center text-muted mt-4" >
29+
<span>{{'vocabulary-treeview.search.no-result' | translate}}</span>
30+
</h2>
31+
</div>
2732
<cdk-tree [dataSource]="dataSource" [treeControl]="treeControl">
2833
<!-- Leaf node -->
2934
<cdk-tree-node *cdkTreeNodeDef="let node" cdkTreeNodePadding class="d-flex">
@@ -88,13 +93,15 @@ <h2 *ngIf="!(loading | async) && dataSource.data.length === 0" class="h4 text-ce
8893
</cdk-tree-node>
8994

9095
<cdk-tree-node *cdkTreeNodeDef="let node; when: isLoadMore" cdkTreeNodePadding>
91-
<button class="btn btn-outline-secondary btn-sm" (click)="loadMore(node.loadMoreParentItem)">
96+
<button class="btn btn-outline-secondary btn-sm" (click)="loadMore(node.loadMoreParentItem)"
97+
[attr.aria-label]="'vocabulary-treeview.load-more' | translate">
9298
{{'vocabulary-treeview.load-more' | translate}}...
9399
</button>
94100
</cdk-tree-node>
95101

96102
<cdk-tree-node *cdkTreeNodeDef="let node; when: isLoadMoreRoot">
97-
<button class="btn btn-outline-secondary btn-sm" (click)="loadMoreRoot(node)">
103+
<button class="btn btn-outline-secondary btn-sm" (click)="loadMoreRoot(node)"
104+
[attr.aria-label]="'vocabulary-treeview.load-more' | translate">
98105
{{'vocabulary-treeview.load-more' | translate}}...
99106
</button>
100107
</cdk-tree-node>

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FlatTreeControl } from '@angular/cdk/tree';
2-
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, OnChanges, SimpleChanges } from '@angular/core';
2+
import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, OnChanges, SimpleChanges, ViewChild } from '@angular/core';
33

44
import { Observable, Subscription } from 'rxjs';
55
import { Store } from '@ngrx/store';
@@ -29,6 +29,11 @@ import { AlertType } from '../../alert/alert-type';
2929
})
3030
export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges {
3131

32+
/**
33+
* Implemented to manage focus on input
34+
*/
35+
@ViewChild('searchInput') searchInput!: ElementRef;
36+
3237
/**
3338
* The {@link VocabularyOptions} object
3439
*/
@@ -294,6 +299,9 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges
294299
this.storedNodeMap = new Map<string, TreeviewFlatNode>();
295300
this.vocabularyTreeviewService.restoreNodes();
296301
}
302+
if (this.searchInput) {
303+
this.searchInput.nativeElement.focus();
304+
}
297305
}
298306

299307
add() {

0 commit comments

Comments
 (0)