Skip to content

[mat-datepicker] proposal: pull request to add option to display a today button in header #13212

@mnahkies

Description

@mnahkies

Bug, feature request, or proposal:

Proposal / Feature

What is the expected behavior?

An option exists to enable a button on the date picker header to jump from the current selection to today.

What is the current behavior?

Not supported

What are the steps to reproduce?

N/A

What is the use-case or motivation for changing an existing behavior?

For some use cases of date picker it is handy to be able to quickly jump from the current selection to today.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

N/A

Is there anything else we should know?

I've made this change in my local clone of material2 and am using it in my project.

It's ready to make a pull request, aside from being based on the current release tag rather than tip of master (I'm unable to get master to build currently) - however the changes apply cleanly to tip of master so easy to transplant.

Given that you support custom header components I'm not sure if you would be willing to accept this, and so thought I'd raise this issue to get some guidance.

I could publish this as an independent module, but as far as I can tell I would need to duplicate the entire "mat-calendar-header" component to do this (which would require ongoing maintenance to keep in sync), and would probably be unable to extend the MatDatepickerIntl to include the string for it.

Please see the attached screenshot for what my change currently looks like. Example usage:

<mat-datepicker showTodayButton="true" #startDatePicker></mat-datepicker>

screenshot from 2018-09-20 10-37-18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions