Skip to content

Commit 8e25f92

Browse files
committed
refactor(time-picker): add HostListner on keydown event #6482
1 parent 1b5c9ab commit 8e25f92

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

projects/igniteui-angular/src/lib/time-picker/time-picker.component.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
AfterViewInit,
1919
Injector,
2020
PipeTransform,
21-
LOCALE_ID, Optional, ContentChildren, QueryList, OnChanges, SimpleChanges
21+
LOCALE_ID, Optional, ContentChildren, QueryList, OnChanges, SimpleChanges, HostListener
2222
} from '@angular/core';
2323
import {
2424
ControlValueAccessor,
@@ -690,7 +690,6 @@ export class IgxTimePickerComponent extends PickerBaseDirective
690690

691691
/** @hidden */
692692
public ngAfterViewInit(): void {
693-
this.attachOnKeydown();
694693
this.subscribeToDateEditorEvents();
695694
this.subscribeToToggleDirectiveEvents();
696695
if (this._ngControl) {
@@ -1038,6 +1037,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
10381037
}
10391038

10401039
/** @hidden @internal */
1040+
@HostListener('keydown', ['$event'])
10411041
public onKeyDown(event: KeyboardEvent): void {
10421042
switch (event.key) {
10431043
case this.platform.KEYMAP.ARROW_UP:
@@ -1432,12 +1432,6 @@ export class IgxTimePickerComponent extends PickerBaseDirective
14321432
}
14331433
}
14341434

1435-
private attachOnKeydown(): void {
1436-
fromEvent(this.getEditElement(), 'keydown')
1437-
.pipe(takeUntil(this._destroy$))
1438-
.subscribe((evt: KeyboardEvent) => this.onKeyDown(evt));
1439-
}
1440-
14411435
private subscribeToDateEditorEvents(): void {
14421436
this.dateTimeEditor.valueChange.pipe(
14431437
takeUntil(this._destroy$)).subscribe(date => {

0 commit comments

Comments
 (0)