Skip to content

Commit

Permalink
fix/date-picker-time-not-update (#7998)
Browse files Browse the repository at this point in the history
* fix(module:date-picker): model not update when change time

* refactor(module:datepicker): ♻️ use existing method to clone
  • Loading branch information
Nicoss54 committed Jul 7, 2023
1 parent 605e969 commit 08d4640
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions components/affix/affix.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ describe('affix-extra', () => {
context = fixture.componentInstance;
dl = fixture.debugElement;
});

afterEach(() => {
fixture.destroy();
});

it('#getOffset', () => {
const ret = fixture.componentInstance.nzAffixComponent.getOffset(
fixture.debugElement.query(By.css('#affix')).nativeElement,
Expand Down
12 changes: 6 additions & 6 deletions components/date-picker/date-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
Component,
ElementRef,
EventEmitter,
forwardRef,
Host,
Inject,
Input,
Expand All @@ -37,7 +36,8 @@ import {
TemplateRef,
ViewChild,
ViewChildren,
ViewEncapsulation
ViewEncapsulation,
forwardRef
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { fromEvent, of as observableOf } from 'rxjs';
Expand All @@ -50,7 +50,7 @@ import { NzFormNoStatusService, NzFormStatusService } from 'ng-zorro-antd/core/f
import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
import { DATE_PICKER_POSITION_MAP, DEFAULT_DATE_PICKER_POSITIONS } from 'ng-zorro-antd/core/overlay';
import { NzDestroyService } from 'ng-zorro-antd/core/services';
import { CandyDate, cloneDate, CompatibleValue, wrongSortOrder } from 'ng-zorro-antd/core/time';
import { CandyDate, CompatibleValue, cloneDate, wrongSortOrder } from 'ng-zorro-antd/core/time';
import {
BooleanInput,
FunctionProp,
Expand All @@ -61,7 +61,7 @@ import {
OnChangeType,
OnTouchedType
} from 'ng-zorro-antd/core/types';
import { getStatusClassNames, InputBoolean, toBoolean, valueFunctionProp } from 'ng-zorro-antd/core/util';
import { InputBoolean, getStatusClassNames, toBoolean, valueFunctionProp } from 'ng-zorro-antd/core/util';
import {
DateHelperService,
NzDatePickerI18nInterface,
Expand Down Expand Up @@ -839,9 +839,9 @@ export class NzDatePickerComponent implements OnInit, OnChanges, AfterViewInit,

// Safe way of setting value with default
private setValue(value: CompatibleDate): void {
const newValue: CompatibleValue = this.datePickerService.makeValue(value);
const newValue = this.datePickerService.makeValue(value);
this.datePickerService.setValue(newValue);
this.datePickerService.initialValue = newValue;
this.datePickerService.initialValue = cloneDate(newValue);
this.cdr.detectChanges();
}

Expand Down

0 comments on commit 08d4640

Please sign in to comment.