Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(timepicker): improve placeholder rendering during initial render #3125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/framework/theme/components/timepicker/timepicker.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,18 @@ export class NbTimePickerDirective<D> 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)
Expand Down Expand Up @@ -270,7 +282,6 @@ export class NbTimePickerDirective<D> implements AfterViewInit, ControlValueAcce
protected calendarTimeModelService: NbCalendarTimeModelService<D>,
protected dateService: NbDateService<D>,
protected renderer: Renderer2,
@Attribute('placeholder') protected placeholder: string,
) {}

/**
Expand All @@ -288,7 +299,7 @@ export class NbTimePickerDirective<D> 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();
Expand Down