Skip to content

Commit ca24713

Browse files
Fixed dropdown accessibility issue
- Removed non-existing dropdownMenuButton references - Added appropriate roles to dropdown menus
1 parent 9e29cfb commit ca24713

11 files changed

Lines changed: 44 additions & 34 deletions

File tree

src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
[attr.data-test]="'import-dropdown' | dsBrowserOnly"
1616
title="{{'mydspace.new-submission-external' | translate}}">
1717
<i class="fa fa-file-import" aria-hidden="true"></i>
18-
<span class="caret"></span>
18+
<span class="caret" aria-hidden="true"></span>
1919
</button>
2020
<div ngbDropdownMenu
21-
class="dropdown-menu"
21+
class="dropdown-menu p-0"
2222
id="importControlsDropdownMenu"
2323
aria-labelledby="dropdownImport">
2424
<ds-entity-dropdown [isSubmission]="false" (selectionChange)="openPage($event)"></ds-entity-dropdown>

src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
[attr.data-test]="'submission-dropdown' | dsBrowserOnly"
1414
title="{{'mydspace.new-submission' | translate}}">
1515
<i class="fa fa-plus-circle" aria-hidden="true"></i>
16-
<span class="caret"></span>
16+
<span class="caret" aria-hidden="true"></span>
1717
</button>
1818
<div ngbDropdownMenu
19-
class="dropdown-menu"
19+
class="dropdown-menu p-0"
2020
id="entityControlsDropdownMenu"
2121
aria-labelledby="dropdownSubmission">
2222
<ds-entity-dropdown [isSubmission]="true" (selectionChange)="openDialog($event)"></ds-entity-dropdown>
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
<div *ngIf="searchField" class="form-group w-100 pr-2 pl-2">
1+
<div *ngIf="searchField" class="form-group w-100 pr-2 pl-2 my-2">
22
<input type="search"
33
class="form-control w-100"
44
(click)="$event.stopPropagation();"
55
placeholder="{{ 'submission.sections.general.search-collection' | translate }}"
66
[formControl]="searchField"
77
#searchFieldEl>
88
</div>
9-
<div class="dropdown-divider"></div>
10-
<ul class="scrollable-menu p-0"
11-
aria-labelledby="dropdownMenuButton"
9+
<div class="dropdown-divider m-0"></div>
10+
<ul class="scrollable-menu p-0 m-0"
11+
role="menu"
1212
(scroll)="onScroll($event)"
1313
infiniteScroll
1414
[infiniteScrollDistance]="1.5"
@@ -18,12 +18,13 @@
1818
[scrollWindow]="false"
1919
(scrolled)="onScrollDown()">
2020

21-
<li class="dropdown-item disabled" *ngIf="searchListCollection?.length == 0 && !(isLoading | async)">
21+
<li class="dropdown-item disabled" role="menuitem" *ngIf="searchListCollection?.length == 0 && !(isLoading | async)">
2222
{{'submission.sections.general.no-collection' | translate}}
2323
</li>
2424
<ng-container *ngIf="searchListCollection?.length > 0">
2525
<li *ngFor="let listItem of searchListCollection"
2626
class="dropdown-item collection-item"
27+
role="menuitem"
2728
title="{{ listItem.collection.name }}"
2829
(click)="onSelect(listItem)">
2930
<div class="list-unstyled mb-0">
@@ -34,9 +35,10 @@
3435
</div>
3536
</li>
3637
</ng-container>
37-
<button class="dropdown-item disabled" *ngIf="(isLoading | async)">
38-
<ds-themed-loading message="{{'loading.default' | translate}}">
39-
</ds-themed-loading>
40-
</button>
41-
38+
<li *ngIf="(isLoading | async)">
39+
<button class="dropdown-item disabled">
40+
<ds-themed-loading message="{{'loading.default' | translate}}">
41+
</ds-themed-loading>
42+
</button>
43+
</li>
4244
</ul>

src/app/shared/collection-dropdown/collection-dropdown.component.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
overflow-x: hidden;
55
}
66

7-
.collection-item {
7+
li:not(:last-of-type), .dropdown-divider {
8+
border-top: none;
89
border-bottom: var(--bs-dropdown-border-width) solid var(--bs-dropdown-border-color);
910
}
1011

src/app/shared/ds-select/ds-select.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class="dropdown-menu"
2323
id="dsSelectDropdownMenu"
2424
aria-labelledby="dsSelectMenuButton">
25-
<div aria-labelledby="dropdownMenuButton">
25+
<div>
2626
<ng-content select=".menu"></ng-content>
2727
</div>
2828
</div>
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
<div
2-
class="scrollable-menu"
3-
aria-labelledby="dropdownMenuButton"
1+
<ul class="scrollable-menu list-unstyled mb-0"
2+
role="menu"
43
(scroll)="onScroll($event)"
54
infiniteScroll
65
[infiniteScrollDistance]="5"
@@ -9,20 +8,23 @@
98
[fromRoot]="true"
109
[scrollWindow]="false"
1110
(scrolled)="onScrollDown()">
12-
<button class="dropdown-item disabled" *ngIf="searchListEntity?.length == 0 && !(isLoadingList | async)">
11+
<li *ngIf="searchListEntity?.length == 0 && !(isLoadingList | async)">
12+
<button class="dropdown-item disabled" role="menuitem">
1313
{{'submission.sections.general.no-entity' | translate}}
1414
</button>
15-
<button *ngFor="let listItem of searchListEntity"
16-
class="dropdown-item entity-item"
15+
</li>
16+
<li *ngFor="let listItem of searchListEntity" class="entity-item text-primary">
17+
<button class="dropdown-item"
18+
role="menuitem"
1719
title="{{ listItem.label }}"
1820
(click)="onSelect(listItem)">
19-
<ul class="list-unstyled mb-0">
20-
<li class="list-item text-truncate text-primary font-weight-bold">{{ listItem.label.toLowerCase() + '.listelement.badge' | translate }}</li>
21-
</ul>
21+
<span class="text-truncate font-weight-bold">{{ listItem.label.toLowerCase() + '.listelement.badge' | translate }}</span>
2222
</button>
23-
<button class="dropdown-item disabled" *ngIf="(isLoadingList | async)" >
23+
</li>
24+
<li *ngIf="(isLoadingList | async)">
25+
<button class="dropdown-item disabled" role="menuitem">
2426
<ds-themed-loading message="{{'loading.default' | translate}}">
2527
</ds-themed-loading>
2628
</button>
27-
28-
</div>
29+
</li>
30+
</ul>

src/app/shared/entity-dropdown/entity-dropdown.component.scss

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
.list-item:active {
2-
color: white !important;
1+
.dropdown-item {
2+
padding: 0.35rem 1rem;
3+
4+
&:active {
5+
color: white !important;
6+
}
37
}
48

59
.scrollable-menu {
@@ -8,7 +12,7 @@
812
overflow-x: hidden;
913
}
1014

11-
.entity-item {
15+
li:not(:last-of-type) .dropdown-item {
1216
border-bottom: var(--bs-dropdown-border-width) solid var(--bs-dropdown-border-color);
1317
}
1418

src/app/shared/entity-dropdown/entity-dropdown.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe('EntityDropdownComponent', () => {
123123
scheduler.flush();
124124

125125
spyOn(component, 'onSelect');
126-
const entityItem = fixture.debugElement.query(By.css('.entity-item:nth-child(2)'));
126+
const entityItem = fixture.debugElement.query(By.css('.entity-item:nth-child(2) button'));
127127
entityItem.triggerEventHandler('click', null);
128128

129129
scheduler.schedule(() => fixture.detectChanges());

src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
aria-expanded="false"
8989
[attr.aria-labelledby]="'label_' + model.id">
9090
<div class="scrollable-menu"
91-
aria-labelledby="scrollableDropdownMenuButton"
9291
infiniteScroll
9392
[infiniteScrollDistance]="2"
9493
[infiniteScrollThrottle]="50"

src/app/submission/form/collection/submission-form-collection.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</button>
3333

3434
<div ngbDropdownMenu
35-
class="dropdown-menu"
35+
class="dropdown-menu p-0"
3636
id="collectionControlsDropdownMenu"
3737
aria-labelledby="collectionControlsMenuButton">
3838
<ds-themed-collection-dropdown

0 commit comments

Comments
 (0)