-
Notifications
You must be signed in to change notification settings - Fork 67
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
DatePicker breaks when using one-digit year #6771
Comments
This is not quite the intended or supported usage of the DatePicker – if you only want a month and a day, you probably should not use a field type that works with full dates anyway; a custom input consisting of a month and a date dropdown would probably be more appropriate, both programmatically and in terms of UX (after all, the user hardly has any use for the calendar dropdown in this use case either). The DatePicker does indeed not support years < 10. This should be noted in the documentation. |
Then you end up having to consider all the logic if date/month/year in combination are valid, see also #6749 Not supporting years < 10 sounds to me to be a bug rather than a documentation issue. |
Yes you do. Regardless, a calendar picker is simply not the appropriate UI component for selecting a month and a date, without a year. As for y<10 support, let's call it both a bug and a documentation issue. |
I totally agree. That makes it so inconvenient that there is no successor to the old DateField component. We have to migrate ca. 50 applications from Vaadin 8 to 24 and most of them use dates in one or the other way. |
Indeed, the V8 DateField was in some ways much more flexible. For your migration, I would recommend implementing your own day+month field, e.g. based on two Selects or ComboBoxes wrapped into a CustomField. Checking the validity of the supplied date (e.g. by trying to instantiate a |
Description
We use DatePicker also for partial dates, e. g. "end of business year" where only day and month are relevant. We initialize the LocalDate object backing the DatePicker with year = 0, but this breaks the component. The set date format is not applied anymore and no other value can be selected. After some testing it turns out that this happens when the year is set to any one-digit number, but it works if the year is >= 10.
Expected outcome
The component is expected to work also with years < 10. It should look like this:
Minimal reproducible example
Steps to reproduce
Create a DatePicker as described above, check the result in the browser. Try to select a value in the calendar popup.
Environment
Vaadin version(s): 24.5.2
OS: Windows 10 22H2
JDK: OpenJDK 21.0.2
Browsers
Issue is not browser related
The text was updated successfully, but these errors were encountered: