Skip to content

Commit

Permalink
fix(module:date-picker): use fixed width when "nzShowTime" settled fo…
Browse files Browse the repository at this point in the history
…r picker (#2236)
  • Loading branch information
wilsoncook authored and vthinkxie committed Oct 11, 2018
1 parent c3c2d26 commit 463a14c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/date-picker/date-range-picker.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[className]="nzClassName"
[placeholder]="nzPlaceHolder"
[size]="nzSize"
[style]="nzStyle"
[style]="pickerStyle"
(openChange)="onOpenChange($event)"
>
<date-range-popup *ngIf="realOpenState"
Expand Down
15 changes: 15 additions & 0 deletions components/date-picker/date-range-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class DateRangePickerComponent extends AbstractPickerComponent implements
return !this.isRange && this.nzShowToday;
}

pickerStyle: object; // Final picker style that contains width fix corrections etc.
extraFooter: TemplateRef<void> | string;

constructor(i18n: NzI18nService, private logger: LoggerService) {
Expand All @@ -61,6 +62,10 @@ export class DateRangePickerComponent extends AbstractPickerComponent implements
if (changes.nzRenderExtraFooter) {
this.extraFooter = valueFunctionProp(this.nzRenderExtraFooter);
}

if (changes.nzShowTime || changes.nzStyle) {
this.setFixedPickerStyle();
}
}

// If has no timepicker and the user select a date by date panel, then close picker
Expand Down Expand Up @@ -93,4 +98,14 @@ export class DateRangePickerComponent extends AbstractPickerComponent implements
onOpenChange(open: boolean): void {
this.nzOnOpenChange.emit(open);
}

// Setup fixed style for picker
private setFixedPickerStyle(): void {
const showTimeFixes: { width?: string } = {};
if (this.nzShowTime) {
showTimeFixes.width = this.isRange ? '350px' : '195px';
}

this.pickerStyle = { ...showTimeFixes, ...this.nzStyle };
}
}

0 comments on commit 463a14c

Please sign in to comment.