Skip to content

Commit

Permalink
fix(timepicker): save lastInputValue when changed via form api (#2718)
Browse files Browse the repository at this point in the history
  • Loading branch information
unumtresocto authored Jun 15, 2021
1 parent 0642d99 commit 74096d0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/framework/theme/components/timepicker/timepicker.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ export class NbTimePickerDirective<D> implements AfterViewInit, ControlValueAcce
* */
@Input() overlayOffset = 8;


/**
* String representation of latest selected date.
* Updated when value is updated programmatically (writeValue), via timepicker (subscribeOnApplyClick)
* or via input field (handleInputChange)
* @docs-private
*/
protected lastInputValue: string;
/**
* Positioning strategy used by overlay.
Expand Down Expand Up @@ -280,7 +287,7 @@ export class NbTimePickerDirective<D> implements AfterViewInit, ControlValueAcce

setupTimepicker() {
if (this.dateService.getId() === 'native' && isDevMode()) {
console.warn('Date.parse noes not support parsing time with custom format.' +
console.warn('Date.parse does not support parsing time with custom format.' +
' See details here https://akveo.github.io/nebular/docs/components/datepicker/overview#native-parse-issue')
}
this.timepicker.setHost(this.hostRef);
Expand Down Expand Up @@ -403,7 +410,10 @@ export class NbTimePickerDirective<D> implements AfterViewInit, ControlValueAcce
protected updateValue(value: D) {
if (value) {
this.timepicker.date = value;
this.inputValue = this.dateService.format(value, this.timepicker.timeFormat).toUpperCase();

const timeString = this.dateService.format(value, this.timepicker.timeFormat).toUpperCase();
this.inputValue = timeString;
this.lastInputValue = timeString;
}
}

Expand Down

0 comments on commit 74096d0

Please sign in to comment.