Skip to content

Commit b36be72

Browse files
author
Ubuntu
committed
fix(search-filters): remove facet region landmarks and group under single section landmark (#5497)
1 parent 2121e47 commit b36be72

4 files changed

Lines changed: 19 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@if (active$ | async) {
22
<div class="facet-filter d-block mb-3 p-3"
3-
[id]="regionId" [attr.aria-labelledby]="toggleId" [ngClass]="{ 'focus': focusBox }" role="region">
3+
[id]="regionId" [attr.aria-labelledby]="toggleId" [ngClass]="{ 'focus': focusBox }">
44
<button (click)="toggle()" (focusin)="focusBox = true" (focusout)="focusBox = false"
55
class="filter-name d-flex" [attr.aria-controls]="regionId" [id]="toggleId"
66
[attr.aria-expanded]="(collapsed$ | async) !== true"

src/app/shared/search/search-filters/search-filter/search-filter.component.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
TestBed,
88
waitForAsync,
99
} from '@angular/core/testing';
10+
import { By } from '@angular/platform-browser';
1011
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
1112
import { RouterModule } from '@angular/router';
1213
import { AppliedFilter } from '@dspace/core/shared/search/models/applied-filter.model';
@@ -94,6 +95,11 @@ describe('SearchFilterComponent', () => {
9495
expect(comp.regionId).toContain('17');
9596
});
9697

98+
it('should not expose individual facet filter as a region landmark', () => {
99+
const facetFilterElement = fixture.debugElement.query(By.css('.facet-filter'));
100+
expect(facetFilterElement.attributes['role']).not.toBe('region');
101+
});
102+
97103
describe('when the toggle method is triggered', () => {
98104
beforeEach(() => {
99105
spyOn(searchFilterService, 'toggle');

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<section [attr.aria-label]="filterLabel + '.filters.head' | translate">
2+
13
@if (inPlaceSearch) {
24
<h3>{{filterLabel+'.filters.head' | translate}}</h3>
35
} @else {
@@ -21,4 +23,4 @@ <h2>{{filterLabel+'.filters.head' | translate}}</h2>
2123
<i class="fas fa-undo"></i> {{"search.filters.reset" | translate}}
2224
</button>
2325
}
24-
26+
</section>

src/app/shared/search/search-filters/search-filters.component.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
TestBed,
88
waitForAsync,
99
} from '@angular/core/testing';
10+
import { By } from '@angular/platform-browser';
1011
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
1112
import { RouterModule } from '@angular/router';
1213
import { APP_CONFIG } from '@dspace/config/app-config.interface';
@@ -68,4 +69,12 @@ describe('SearchFiltersComponent', () => {
6869
});
6970
});
7071

72+
describe('accessibility', () => {
73+
it('should render a section landmark with an accessible aria-label', () => {
74+
const sectionElement = fixture.debugElement.query(By.css('section'));
75+
expect(sectionElement).toBeTruthy();
76+
expect(sectionElement.attributes['aria-label']).toBeTruthy();
77+
});
78+
});
79+
7180
});

0 commit comments

Comments
 (0)