Skip to content

Commit

Permalink
fix(module:date-picker): get input width before panel open (#5357)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenqi73 authored Jun 5, 2020
1 parent 896f283 commit 39a6c28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions components/date-picker/picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ export class NzPickerComponent implements OnInit, AfterViewInit, OnChanges, OnDe
}

if (this.isRange) {
this.resetInputWidthAndArrowLeft();
fromEvent(window, 'resize')
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
Expand Down Expand Up @@ -291,7 +290,7 @@ export class NzPickerComponent implements OnInit, AfterViewInit, OnChanges, OnDe
}

resetInputWidthAndArrowLeft(): void {
this.inputWidth = this.rangePickerInputs?.first.nativeElement.offsetWidth || 0;
this.inputWidth = this.rangePickerInputs?.first?.nativeElement.offsetWidth || 0;
this.arrowLeft = this.inputWidth + this.separatorElement?.nativeElement.offsetWidth || 0;
}

Expand Down Expand Up @@ -321,6 +320,7 @@ export class NzPickerComponent implements OnInit, AfterViewInit, OnChanges, OnDe
// Show overlay content
showOverlay(): void {
if (!this.realOpenState) {
this.resetInputWidthAndArrowLeft();
this.overlayOpen = true;
this.animationStart();
this.focus();
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/range-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ class NzTestRangePickerComponent {
nzSize!: string;
nzStyle!: NgStyleInterface;
nzOnOpenChange(): void {}
modelValue!: Array<Date | null>;
modelValue: Array<Date | null> = [];
modelValueChange(): void {}
nzDefaultPickerValue!: Array<Date | null>;
nzSeparator!: string;
Expand Down

0 comments on commit 39a6c28

Please sign in to comment.