@@ -12,14 +12,18 @@ import {
1212 Router ,
1313 RouterLink ,
1414} from '@angular/router' ;
15- import { TranslateModule } from '@ngx-translate/core' ;
15+ import {
16+ TranslateModule ,
17+ TranslateService ,
18+ } from '@ngx-translate/core' ;
1619import { Observable } from 'rxjs' ;
1720import { map } from 'rxjs/operators' ;
1821
1922import { PaginationService } from '../../../../../../core/pagination/pagination.service' ;
20- import { SearchService } from '../../../../../../core/shared/search/search.service' ;
2123import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service' ;
2224import { SearchFilterService } from '../../../../../../core/shared/search/search-filter.service' ;
25+ import { SearchService } from '../../../../../../core/shared/search/search.service' ;
26+ import { LiveRegionService } from '../../../../../../shared/live-region/live-region.service' ;
2327import { currentPath } from '../../../../../utils/route.utils' ;
2428import { ShortNumberPipe } from '../../../../../utils/short-number.pipe' ;
2529import { FacetValue } from '../../../../models/facet-value.model' ;
@@ -70,11 +74,18 @@ export class SearchFacetOptionComponent implements OnInit {
7074
7175 paginationId : string ;
7276
77+ /**
78+ * Stores selected filters
79+ */
80+ selectedFilters = new Set ( ) ;
81+
7382 constructor ( protected searchService : SearchService ,
7483 protected filterService : SearchFilterService ,
7584 protected searchConfigService : SearchConfigurationService ,
7685 protected router : Router ,
7786 protected paginationService : PaginationService ,
87+ protected liveRegionService : LiveRegionService ,
88+ private translateService : TranslateService ,
7889 ) {
7990 }
8091
@@ -119,4 +130,25 @@ export class SearchFacetOptionComponent implements OnInit {
119130 return getFacetValueForType ( this . filterValue , this . filterConfig ) ;
120131 }
121132
133+ /**
134+ * Announces to the screen reader that the page will be reloaded, which filter has been selected
135+ * and then implement “filterService.minimizeAll()”
136+ */
137+ selectingFilter ( ) {
138+ const filterValue = this . filterValue . value ;
139+ if ( ! this . selectedFilters . has ( filterValue ) ) {
140+ this . translateService . get ( 'search-facet-option.update.announcement' )
141+ . subscribe ( translatedMessage => {
142+ const message = `${ translatedMessage } ${ filterValue } ` ;
143+ this . liveRegionService . addMessage ( message ) ;
144+
145+ setTimeout ( ( ) => {
146+ this . liveRegionService . clear ( ) ;
147+ } , this . liveRegionService . getMessageTimeOutMs ( ) ) ;
148+ this . selectedFilters . add ( filterValue ) ;
149+ } ) ;
150+ }
151+ this . filterService . minimizeAll ( ) ;
152+ }
153+
122154}
0 commit comments