Skip to content

Commit b15325f

Browse files
SkyZeroZxthePunderWoman
authored andcommitted
refactor(devtools): replace HostListener with host metadata for keydown handling
Uses host metadata instead of the HostListener decorator for keydown events (cherry picked from commit c74367c)
1 parent 59798a1 commit b15325f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

devtools/projects/ng-devtools/src/lib/devtools-tabs/directive-explorer/directive-forest/directive-forest.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ const RESIZE_OBSERVER_DEBOUNCE = 250; // ms
5454
CdkVirtualForOf,
5555
TreeNodeComponent,
5656
],
57+
host: {
58+
'(document:keydown.ArrowUp)': 'navigateUp($event)',
59+
'(document:keydown.ArrowDown)': 'navigateDown($event)',
60+
'(document:keydown.ArrowLeft)': 'collapseCurrent($event)',
61+
'(document:keydown.ArrowRight)': 'expandCurrent($event)',
62+
},
5763
})
5864
export class DirectiveForestComponent {
5965
private readonly tabUpdate = inject(TabUpdate);
@@ -174,7 +180,6 @@ export class DirectiveForestComponent {
174180
this.setParents.emit(null);
175181
}
176182

177-
@HostListener('document:keydown.ArrowUp', ['$event'])
178183
navigateUp(event: Event): void {
179184
if (this.isEditingDirectiveState(event)) {
180185
return;
@@ -199,7 +204,6 @@ export class DirectiveForestComponent {
199204
this.selectAndEnsureVisible(data[prevIdx]);
200205
}
201206

202-
@HostListener('document:keydown.ArrowDown', ['$event'])
203207
navigateDown(event: Event): void {
204208
if (this.isEditingDirectiveState(event)) {
205209
return;
@@ -227,7 +231,6 @@ export class DirectiveForestComponent {
227231
this.selectAndEnsureVisible(data[idx]);
228232
}
229233

230-
@HostListener('document:keydown.ArrowLeft', ['$event'])
231234
collapseCurrent(event: Event): void {
232235
if (this.isEditingDirectiveState(event)) {
233236
return;
@@ -240,7 +243,6 @@ export class DirectiveForestComponent {
240243
event.preventDefault();
241244
}
242245

243-
@HostListener('document:keydown.ArrowRight', ['$event'])
244246
expandCurrent(event: Event): void {
245247
if (this.isEditingDirectiveState(event)) {
246248
return;

0 commit comments

Comments
 (0)