Skip to content

Commit

Permalink
refactor(time-picker): add HostListner on keydown event #6482
Browse files Browse the repository at this point in the history
  • Loading branch information
PlamenaMiteva committed Apr 19, 2021
1 parent 1b5c9ab commit 8e25f92
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
AfterViewInit,
Injector,
PipeTransform,
LOCALE_ID, Optional, ContentChildren, QueryList, OnChanges, SimpleChanges
LOCALE_ID, Optional, ContentChildren, QueryList, OnChanges, SimpleChanges, HostListener
} from '@angular/core';
import {
ControlValueAccessor,
Expand Down Expand Up @@ -690,7 +690,6 @@ export class IgxTimePickerComponent extends PickerBaseDirective

/** @hidden */
public ngAfterViewInit(): void {
this.attachOnKeydown();
this.subscribeToDateEditorEvents();
this.subscribeToToggleDirectiveEvents();
if (this._ngControl) {
Expand Down Expand Up @@ -1038,6 +1037,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
}

/** @hidden @internal */
@HostListener('keydown', ['$event'])
public onKeyDown(event: KeyboardEvent): void {
switch (event.key) {
case this.platform.KEYMAP.ARROW_UP:
Expand Down Expand Up @@ -1432,12 +1432,6 @@ export class IgxTimePickerComponent extends PickerBaseDirective
}
}

private attachOnKeydown(): void {
fromEvent(this.getEditElement(), 'keydown')
.pipe(takeUntil(this._destroy$))
.subscribe((evt: KeyboardEvent) => this.onKeyDown(evt));
}

private subscribeToDateEditorEvents(): void {
this.dateTimeEditor.valueChange.pipe(
takeUntil(this._destroy$)).subscribe(date => {
Expand Down

0 comments on commit 8e25f92

Please sign in to comment.