Skip to content

Commit 8bc7ee9

Browse files
crisbetoandrewseguin
authored andcommitted
refactor(datepicker): remove 6.0.0 deletion targets (#10413)
Removes the deletion targets for 6.0.0 from `material/datepicker`. BREAKING CHANGES: * `selectedChanged` has been removed. Use `dateChange` or `dateInput` from `MatDatepickerInput`.
1 parent f0bf6e7 commit 8bc7ee9

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

src/lib/datepicker/datepicker-input.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,13 @@ export class MatDatepickerInput<D> implements AfterContentInit, ControlValueAcce
254254

255255
ngAfterContentInit() {
256256
if (this._datepicker) {
257-
this._datepickerSubscription =
258-
this._datepicker.selectedChanged.subscribe((selected: D) => {
259-
this.value = selected;
260-
this._cvaOnChange(selected);
261-
this._onTouched();
262-
this.dateInput.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
263-
this.dateChange.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
264-
});
257+
this._datepickerSubscription = this._datepicker._selectedChanged.subscribe((selected: D) => {
258+
this.value = selected;
259+
this._cvaOnChange(selected);
260+
this._onTouched();
261+
this.dateInput.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
262+
this.dateChange.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement));
263+
});
265264
}
266265
}
267266

src/lib/datepicker/datepicker.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ describe('MatDatepicker', () => {
232232
it('clicking the currently selected date should close the calendar ' +
233233
'without firing selectedChanged', fakeAsync(() => {
234234
const selectedChangedSpy =
235-
spyOn(testComponent.datepicker.selectedChanged, 'emit').and.callThrough();
235+
spyOn(testComponent.datepicker._selectedChanged, 'next').and.callThrough();
236236

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

261261
testComponent.datepicker.open();
262262
fixture.detectChanges();

src/lib/datepicker/datepicker.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,6 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
236236
}
237237
private _disabled: boolean;
238238

239-
/**
240-
* Emits new selected date when selected date changes.
241-
* @deprecated Switch to the `dateChange` and `dateInput` binding on the input element.
242-
* @deletion-target 6.0.0
243-
*/
244-
@Output() readonly selectedChanged: EventEmitter<D> = new EventEmitter<D>();
245-
246239
/**
247240
* Emits selected year in multiyear view.
248241
* This doesn't imply a change on the selected date.
@@ -317,6 +310,9 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
317310
/** Emits when the datepicker is disabled. */
318311
readonly _disabledChange = new Subject<boolean>();
319312

313+
/** Emits new selected date when selected date changes. */
314+
readonly _selectedChanged = new Subject<D>();
315+
320316
constructor(private _dialog: MatDialog,
321317
private _overlay: Overlay,
322318
private _ngZone: NgZone,
@@ -346,7 +342,7 @@ export class MatDatepicker<D> implements OnDestroy, CanColor {
346342
let oldValue = this._selected;
347343
this._selected = date;
348344
if (!this._dateAdapter.sameDate(oldValue, this._selected)) {
349-
this.selectedChanged.emit(date);
345+
this._selectedChanged.next(date);
350346
}
351347
}
352348

0 commit comments

Comments
 (0)