Skip to content

introduce onOpen and onClose Events to Datepicker #7990

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

Closed
wants to merge 2 commits into from
Closed
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
8 changes: 8 additions & 0 deletions src/lib/datepicker/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ export class MatDatepicker<D> implements OnDestroy {
*/
@Input() touchUi = false;

/** Event emitted when the datepicker has been opened. */
@Output() onOpen: EventEmitter<void> = new EventEmitter<void>();

/** Event emitted when the datepicker has been closed. */
@Output() onClose: EventEmitter<void> = new EventEmitter<void>();

/** Whether the datepicker pop-up should be disabled. */
@Input()
get disabled() {
Expand Down Expand Up @@ -271,6 +277,7 @@ export class MatDatepicker<D> implements OnDestroy {

this.touchUi ? this._openAsDialog() : this._openAsPopup();
this.opened = true;
this.onOpen.emit();
}

/** Close the calendar. */
Expand All @@ -296,6 +303,7 @@ export class MatDatepicker<D> implements OnDestroy {
}

this.opened = false;
this.onClose.emit();
}

/** Open the calendar as a dialog. */
Expand Down