Skip to content

Commit c7fec8b

Browse files
committed
Update keydownEvents to be in dialog.directive
1 parent a19038d commit c7fec8b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/dialog/dialog.directive.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
114114
this.toggle();
115115
}
116116

117+
@HostListener("keydown", ["$event"])
118+
onKeydown(event: KeyboardEvent) {
119+
if (this.trigger === "click" && (event.key === "Enter" || event.key === " " )) {
120+
this.open();
121+
}
122+
if (event.key === "Escape") {
123+
this.close();
124+
}
125+
}
126+
117127
ngOnChanges() {
118128
// set the config object (this can [and should!] be added to in child classes depending on what they need)
119129
this.dialogConfig = {

src/dialog/tooltip/tooltip.directive.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,4 @@ export class TooltipDirective extends DialogDirective {
8686
this.dialogService.close(this.viewContainerRef, false);
8787
this.expanded = false;
8888
}
89-
90-
@HostListener("keydown", ["$event"])
91-
onKeydown(event: KeyboardEvent) {
92-
if (this.trigger === "click" && (event.key === "Enter" || event.key === " " )) {
93-
this.open();
94-
}
95-
if (event.key === "Escape") {
96-
this.close();
97-
}
98-
}
9989
}

0 commit comments

Comments
 (0)