Skip to content
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

[BUG] - Empty DatePicker doesn't accept 31 as day if no month is given. #2913

Closed
jannikdresselhaus opened this issue Apr 29, 2024 · 2 comments

Comments

@jannikdresselhaus
Copy link

NextUI Version

2.3.6

Describe the bug

When there is a datepicker with no value, it is not possible to start with the 31st of the month when inputting via keyboard. Instead, you have to first input a month with 31 days.

For a locale with a day-month-year date format this is unexpected behaviour.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

Create a datepicker with no value and try to put in 31 as a day.

Expected behavior

I expect to be able to put in 31 as a day. When I then try to input a month with less than 31 days, the day field should be reset to null.

Screenshots or Videos

Example

Operating System Version

macOS/Ubuntu

Browser

Chrome

Copy link

linear bot commented Apr 29, 2024

@jannikdresselhaus jannikdresselhaus changed the title [BUG] - Empty dateinput doesn't accept 31 as date if no month is filled out. [BUG] - Empty DatePicker doesn't accept 31 as date if no month is filled out. Apr 29, 2024
@jannikdresselhaus jannikdresselhaus changed the title [BUG] - Empty DatePicker doesn't accept 31 as date if no month is filled out. [BUG] - Empty DatePicker doesn't accept 31 as day if no month is given. Apr 29, 2024
@ryo-manba
Copy link
Member

ryo-manba commented Apr 30, 2024

This is probably a bug in react-aria that we use in our implementation. This is because there is always a date under the hood, even when the placeholder is displayed.
See: adobe/react-spectrum#3256

The default is today's date, but you can also set it using the placeholderValue property.

import {CalendarDate} from '@internationalized/date';

<DatePicker
  label="Birth date"
  placeholderValue={new CalendarDate(2020, 12, 1)}
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants