-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(igxExpansionPanel): fix labelledBy binding, adjust tests, #307
- Loading branch information
1 parent
38839a3
commit 3200d3f
Showing
3 changed files
with
68 additions
and
41 deletions.
There are no files selected for viewing
30 changes: 22 additions & 8 deletions
30
projects/igniteui-angular/src/lib/expansion-panel/expansion-panel-body.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,48 @@ | ||
import { Component, HostBinding, Inject, forwardRef, ElementRef, Input } from '@angular/core'; | ||
import { Component, HostBinding, Inject, | ||
forwardRef, ElementRef, Input, AfterViewInit, ChangeDetectorRef, OnInit } from '@angular/core'; | ||
import { IgxExpansionPanelComponent } from './expansion-panel.component'; | ||
import { IgxExpansionPanelTitleDirective } from './expansion-panel.directives'; | ||
|
||
@Component({ | ||
// tslint:disable-next-line:directive-selector | ||
selector: 'igx-expansion-panel-body', | ||
template: ` | ||
<ng-content></ng-content>` | ||
template: `<ng-content></ng-content>` | ||
}) | ||
export class IgxExpansionPanelBodyComponent { | ||
export class IgxExpansionPanelBodyComponent implements OnInit { | ||
private _labelledBy = ''; | ||
private _label = ''; | ||
constructor(@Inject(forwardRef(() => IgxExpansionPanelComponent)) | ||
public panel: IgxExpansionPanelComponent, public element: ElementRef) { | ||
public panel: IgxExpansionPanelComponent, public element: ElementRef, | ||
public cdr: ChangeDetectorRef) { | ||
} | ||
@HostBinding('class.igx-expansion-panel__body') | ||
public cssClass = `igx-expansion-panel__body`; | ||
public _title = ''; | ||
|
||
@Input() | ||
@HostBinding('attr.aria-label') | ||
public label = this.panel.id + '-region'; | ||
public get label(): string { | ||
return this._label || this.panel.id + '-region'; | ||
} | ||
public set label(val: string) { | ||
this._label = val; | ||
} | ||
|
||
@Input() | ||
@HostBinding('attr.aria-labelledby') | ||
public get labelledBy(): string { | ||
return this.panel.title ? this.panel.title.id : this._title; | ||
return this._labelledBy; | ||
} | ||
public set labelledBy(val: string) { | ||
this._title = val; | ||
this._labelledBy = val; | ||
} | ||
|
||
@Input() | ||
@HostBinding('attr.role') | ||
public role = 'region'; | ||
|
||
ngOnInit() { | ||
this.labelledBy = this.panel.headerId; | ||
this.label = this.panel.id + '-region'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters