From e6f0a0e3c0f37492b8507ad63188c03bf2cbd310 Mon Sep 17 00:00:00 2001 From: sashaqred Date: Tue, 25 Oct 2022 20:15:01 +0400 Subject: [PATCH] fix(timepicker): improve placeholder rendering during initial render --- .../components/timepicker/timepicker.directive.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/framework/theme/components/timepicker/timepicker.directive.ts b/src/framework/theme/components/timepicker/timepicker.directive.ts index 5a292b3902..60947d5b77 100644 --- a/src/framework/theme/components/timepicker/timepicker.directive.ts +++ b/src/framework/theme/components/timepicker/timepicker.directive.ts @@ -214,6 +214,18 @@ export class NbTimePickerDirective implements AfterViewInit, ControlValueAcce * */ @Input() overlayOffset = 8; + @Input() + set placeholder(value: string) { + this._placeholder = value; + this.hasCustomPlaceholder = true; + this.renderer.setProperty(this.input, 'placeholder', value); + } + get placeholder(): string { + return this._placeholder; + } + private _placeholder: string; + protected hasCustomPlaceholder: boolean = false; + /** * String representation of latest selected date. * Updated when value is updated programmatically (writeValue), via timepicker (subscribeOnApplyClick) @@ -270,7 +282,6 @@ export class NbTimePickerDirective implements AfterViewInit, ControlValueAcce protected calendarTimeModelService: NbCalendarTimeModelService, protected dateService: NbDateService, protected renderer: Renderer2, - @Attribute('placeholder') protected placeholder: string, ) {} /** @@ -288,7 +299,7 @@ export class NbTimePickerDirective implements AfterViewInit, ControlValueAcce ngAfterViewInit() { this.subscribeOnInputChange(); - if (!this.placeholder) { + if (!this.hasCustomPlaceholder) { this.renderer.setProperty(this.input, 'placeholder', this.timepicker.computedTimeFormat); } this.triggerStrategy = this.createTriggerStrategy();