I need the screen reader to read "All Filters Are Removed" when all the filter items are removed. The tricky part is: when the active filter component is removed, there's no other element for me to set aria-label to All filters are removed. I was wondering how to force the screen reader to read something in this case?
The HTML Example is here:
<div *ngIf="activeFilters.length > 0">
<div class="active-filters" attr.aria-label="{{'List of active filters'}}">
<h4 class="active-filters-headline">{{'Active filters'}}</h4>
</div>
</div>
When all the filter items are removed, the active-filters component will not show up. Because the activeFilters.length would be 0. So I am not sure how to put aria-label on the element that does not exist.
Here is the typescript code that could potentially introduce the screen reader logic:
ngAfterViewChecked() {
if (this.interaction && this.interactionDataDelivery) {
this.interaction = this.interactionDataDelivery = false;
if (this.activeFilters.length == 0) {
//How do I set up the aria-label?
}
}
}