vaadin / flow-components

Java counterpart of Vaadin Web Components
102 stars 65 forks source link

DatePicker: allow input of partial dates #6749

Open gunnarschmid opened 1 month ago

gunnarschmid commented 1 month ago

Describe your motivation

In Vaadin 8 you could use the DateField (by setting DateFormat and Resolution) to allow entering partial dates, e. g. dd.mm. or mm.yyyy. This is not possible with Flow's DatePicker.

Describe the solution you'd like

Please either extend DatePicker or add DateField component to allow partial dates.

Describe alternatives you've considered

As an alternative one can use a CustomField with some Selects, but this requires some manual work for data binding, updating one Select by the value of another (different number of days depending on month and leap year) etc. A standard component would be highly appreciated.

sissbruecker commented 1 month ago

In principle that should be doable using custom date formats. For example:

        DatePicker datePicker1 = new DatePicker();
        datePicker1.setI18n(new DatePicker.DatePickerI18n().setDateFormat("dd.MM."));

        DatePicker datePicker2 = new DatePicker();
        datePicker2.setI18n(new DatePicker.DatePickerI18n().setDateFormat("MM.yyyy"));

https://github.com/user-attachments/assets/90578e5e-d302-4a04-80f3-33660a915a29

Is there anything in specific that doesn't work?

gunnarschmid commented 1 month ago

Hello Sascha, thanks a lot for your reply. I'm pretty sure that I tested that before and had some issue, but right now I can neither remember nor reproduce what the problem was. I'll test again and report here soon.