Skip to content

Commit c9276f1

Browse files
authored
Merge pull request #8154 from IgniteUI/iganchev/select-aria-8079-master
fix(select): Add aria-labelledby for listbox - 10.2.x
2 parents a14f81e + 9c767bb commit c9276f1

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ All notable changes for each version of this project will be documented in this
77
- `IgxInputGroup`
88
- **Breaking Chage** - Removed `fluent`, `fluent_search`, `bootstrap`, and `indigo` as possible values for the `type` input property.
99
- **Behavioral Change** - The styling of the input group is now dictated by the theme being used. The remaining `types` - `line`, `border`, and `box` will only have effect on the styling when used with the `material` theme. The `search` type will affect styling when used with all themes. Changing the theme at runtime will not change the styling of the input group, a page refresh is required.
10+
- `IgxSelect`
11+
- Added `aria-labelledby` property for the items list container(marked as `role="listbox"`). This will ensure the users of assistive technologies will also know what the list items container is used for, upon opening.
1012

1113
### New Features
1214
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`

projects/igniteui-angular/src/lib/select/select.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[value]="this.selectionValue"
1313
role="combobox"
1414
aria-haspopup="listbox"
15-
[attr.aria-labelledby]="this.label ? this.label.id : ''"
15+
[attr.aria-labelledby]="this.label?.id"
1616
[attr.aria-expanded]="!this.collapsed"
1717
[attr.aria-owns]="this.listId"
1818
[attr.aria-activedescendant]="!this.collapsed ? this.focusedItem?.id : null"
@@ -40,7 +40,8 @@
4040
</div>
4141

4242
<!-- #7436 LMB scrolling closes items container - unselectable attribute is IE specific -->
43-
<div #scrollContainer class="igx-drop-down__list-scroll" unselectable="on" [style.maxHeight]="maxHeight" [attr.id]="this.listId" role="listbox">
43+
<div #scrollContainer class="igx-drop-down__list-scroll" unselectable="on" [style.maxHeight]="maxHeight"
44+
[attr.id]="this.listId" role="listbox" [attr.aria-labelledby]="this.label?.id">
4445
<ng-content select="igx-select-item, igx-select-item-group"></ng-content>
4546
</div>
4647

projects/igniteui-angular/src/lib/select/select.component.spec.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IgxInputState } from './../directives/input/input.directive';
2-
import { Component, ViewChild, DebugElement, OnInit, ViewChildren, QueryList } from '@angular/core';
2+
import { Component, ViewChild, DebugElement, OnInit, ViewChildren, QueryList, ElementRef } from '@angular/core';
33
import { async, TestBed, tick, fakeAsync } from '@angular/core/testing';
44
import { FormsModule, FormGroup, FormBuilder, FormControl, Validators, ReactiveFormsModule, NgForm, NgControl } from '@angular/forms';
55
import { By } from '@angular/platform-browser';
@@ -381,8 +381,11 @@ describe('igxSelect', () => {
381381
const dropdownListElement = fixture.debugElement.query(By.css('.' + CSS_CLASS_DROPDOWN_LIST_SCROLL));
382382
const dropdownWrapper = fixture.debugElement.query(By.css('.' + CSS_CLASS_DROPDOWN_LIST));
383383
const toggleBtn = fixture.debugElement.query(By.css('.' + CSS_CLASS_TOGGLE_BUTTON));
384+
const labelID = fixture.componentInstance.label1.nativeElement.getAttribute('id');
384385
expect(inputElement.nativeElement.getAttribute('role')).toEqual('combobox');
385386
expect(inputElement.nativeElement.getAttribute('aria-haspopup')).toEqual('listbox');
387+
expect(inputElement.nativeElement.getAttribute('aria-labelledby')).toEqual(labelID);
388+
expect(dropdownListElement.nativeElement.getAttribute('aria-labelledby')).toEqual(labelID);
386389
expect(inputElement.nativeElement.getAttribute('aria-owns')).toEqual(select.listId);
387390
expect(inputElement.nativeElement.getAttribute('aria-expanded')).toEqual('false');
388391
expect(toggleBtn.nativeElement.getAttribute('aria-hidden')).toEqual('true');
@@ -2658,15 +2661,18 @@ describe('igxSelect ControlValueAccessor Unit', () => {
26582661
@Component({
26592662
template: `
26602663
<igx-select #select [width]="'300px'" [height]="'200px'" [placeholder]="'Choose a city'" [(ngModel)]="value">
2661-
<igx-select-item *ngFor="let item of items" [value]="item" [text]="item">
2662-
{{ item }} {{'©'}}
2663-
</igx-select-item>
2664+
<label igxLabel #simpleLabel>Select Simple Component</label>
2665+
<igx-select-item *ngFor="let item of items" [value]="item" [text]="item">
2666+
{{ item }} {{'©'}}
2667+
</igx-select-item>
26642668
</igx-select>
26652669
`
26662670
})
26672671
class IgxSelectSimpleComponent {
26682672
@ViewChild('select', { read: IgxSelectComponent, static: true })
26692673
public select: IgxSelectComponent;
2674+
@ViewChild('simpleLabel', { read: ElementRef, static: true })
2675+
public label1: ElementRef;
26702676
public items: string[] = [
26712677
'New York',
26722678
'Sofia',

0 commit comments

Comments
 (0)