Skip to content

Commit 0a92bb7

Browse files
authored
Merge branch 'master' into master
2 parents 113b634 + 0ad6ab5 commit 0a92bb7

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/dialog/dialog.directive.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
TemplateRef,
1010
ViewContainerRef,
1111
HostListener,
12-
OnChanges
12+
OnChanges,
13+
HostBinding
1314
} from "@angular/core";
1415
import { fromEvent } from "rxjs";
1516
import { DialogService } from "./dialog.service";
@@ -94,6 +95,9 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
9495
@Output() onClose: EventEmitter<any> = new EventEmitter<any>();
9596
dialogConfig: DialogConfig;
9697

98+
@HostBinding("attr.role") role = "button";
99+
@HostBinding("attr.aria-expanded") expanded = false;
100+
97101
/**
98102
* Creates an instance of DialogDirective.
99103
* @param {ElementRef} elementRef
@@ -158,7 +162,7 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
158162
this.dialogService.isClosed.subscribe(value => {
159163
if (value) {
160164
this.onClose.emit();
161-
this.elementRef.nativeElement.setAttribute("aria-expanded", "false");
165+
this.expanded = false;
162166
}
163167
});
164168

@@ -182,7 +186,7 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
182186
*/
183187
open() {
184188
this.dialogService.open(this.viewContainerRef, this.dialogConfig);
185-
this.elementRef.nativeElement.setAttribute("aria-expanded", "true");
189+
this.expanded = true;
186190
}
187191

188192
/**
@@ -192,7 +196,7 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
192196
*/
193197
toggle() {
194198
this.dialogService.toggle(this.viewContainerRef, this.dialogConfig);
195-
this.elementRef.nativeElement.setAttribute("aria-expanded", this.dialogService.isOpen);
199+
this.expanded = this.dialogService.isOpen;
196200
}
197201

198202
/**
@@ -202,7 +206,7 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
202206
*/
203207
close() {
204208
this.dialogService.close(this.viewContainerRef);
205-
this.elementRef.nativeElement.setAttribute("aria-expanded", "false");
209+
this.expanded = false;
206210
}
207211

208212
/**

src/dialog/tooltip/tooltip.directive.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
ElementRef,
66
Injector,
77
ComponentFactoryResolver,
8-
ViewContainerRef
8+
ViewContainerRef,
9+
HostBinding
910
} from "@angular/core";
1011
import { DialogDirective } from "./../dialog.directive";
1112
import { Tooltip } from "./tooltip.component";
@@ -64,6 +65,8 @@ export class TooltipDirective extends DialogDirective {
6465
// tslint:disable-next-line:no-input-rename
6566
@Input("tooltip-type") tooltipType: "warning" | "error" | "" = "";
6667

68+
@HostBinding("attr.aria-describedby") descriptorId: string;
69+
6770
/**
6871
* Creates an instance of `TooltipDirective`.
6972
* @param {ElementRef} elementRef
@@ -89,6 +92,6 @@ export class TooltipDirective extends DialogDirective {
8992
this.dialogConfig.compID = "tooltip-" + TooltipDirective.tooltipCounter;
9093
this.dialogConfig.content = this.ibmTooltip;
9194
this.dialogConfig.type = this.tooltipType !== undefined ? this.tooltipType : this.type;
92-
this.elementRef.nativeElement.setAttribute("aria-describedby", this.dialogConfig.compID);
95+
this.descriptorId = this.dialogConfig.compID;
9396
}
9497
}

0 commit comments

Comments
 (0)