Skip to content

Commit

Permalink
Added input box focusable when the date is selected from the calendar.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekeh committed Dec 6, 2017
1 parent 9daeb92 commit 779e29d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ngx-my-date-picker/ngx-my-date-picker.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export class NgxMyDatePickerDirective implements OnChanges, ControlValueAccessor
this.getSelectorPosition(this.elem.nativeElement),
this.elem.nativeElement.value,
(dm: IMyDateModel, close: boolean) => {
this.focusToInput();
this.emitDateChanged(dm);
this.emitInputFieldChanged(dm.formatted, true);
this.updateModel(dm);
Expand Down Expand Up @@ -278,6 +279,12 @@ export class NgxMyDatePickerDirective implements OnChanges, ControlValueAccessor
this.renderer.setElementProperty(this.elem.nativeElement, "value", value);
}

private focusToInput(): void {
setTimeout(()=> {
this.elem.nativeElement.focus();
});
}

private emitDateChanged(dateModel: IMyDateModel): void {
this.dateChanged.emit(dateModel);
}
Expand Down

0 comments on commit 779e29d

Please sign in to comment.