Skip to content

refactor(datepicker): remove 6.0.0 deletion targets #10413

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

Merged
Merged
Show file tree
Hide file tree
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: 7 additions & 8 deletions src/lib/datepicker/datepicker-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,13 @@ export class MatDatepickerInput<D> implements AfterContentInit, ControlValueAcce

ngAfterContentInit() {
if (this._datepicker) {
this._datepickerSubscription =
this._datepicker.selectedChanged.subscribe((selected: D) => {
this.value = selected;
this._cvaOnChange(selected);
this._onTouched();
this.dateInput.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
this.dateChange.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
});
this._datepickerSubscription = this._datepicker._selectedChanged.subscribe((selected: D) => {
this.value = selected;
this._cvaOnChange(selected);
this._onTouched();
this.dateInput.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
this.dateChange.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
});
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/datepicker/datepicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ describe('MatDatepicker', () => {
it('clicking the currently selected date should close the calendar ' +
'without firing selectedChanged', fakeAsync(() => {
const selectedChangedSpy =
spyOn(testComponent.datepicker.selectedChanged, 'emit').and.callThrough();
spyOn(testComponent.datepicker._selectedChanged, 'next').and.callThrough();

for (let changeCount = 1; changeCount < 3; changeCount++) {
const currentDay = changeCount;
Expand All @@ -256,7 +256,7 @@ describe('MatDatepicker', () => {
it('pressing enter on the currently selected date should close the calendar without ' +
'firing selectedChanged', () => {
const selectedChangedSpy =
spyOn(testComponent.datepicker.selectedChanged, 'emit').and.callThrough();
spyOn(testComponent.datepicker._selectedChanged, 'next').and.callThrough();

testComponent.datepicker.open();
fixture.detectChanges();
Expand Down
12 changes: 4 additions & 8 deletions src/lib/datepicker/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,6 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
}
private _disabled: boolean;

/**
* Emits new selected date when selected date changes.
* @deprecated Switch to the `dateChange` and `dateInput` binding on the input element.
* @deletion-target 6.0.0
*/
@Output() readonly selectedChanged: EventEmitter<D> = new EventEmitter<D>();

/**
* Emits selected year in multiyear view.
* This doesn't imply a change on the selected date.
Expand Down Expand Up @@ -317,6 +310,9 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
/** Emits when the datepicker is disabled. */
readonly _disabledChange = new Subject<boolean>();

/** Emits new selected date when selected date changes. */
readonly _selectedChanged = new Subject<D>();

constructor(private _dialog: MatDialog,
private _overlay: Overlay,
private _ngZone: NgZone,
Expand Down Expand Up @@ -346,7 +342,7 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
let oldValue = this._selected;
this._selected = date;
if (!this._dateAdapter.sameDate(oldValue, this._selected)) {
this.selectedChanged.emit(date);
this._selectedChanged.next(date);
}
}

Expand Down