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] - DatePicker unexpectedly closes when value changes from null to a CalendarDateTime #3898

Open
lilkimo opened this issue Oct 16, 2024 · 3 comments

Comments

@lilkimo
Copy link

lilkimo commented Oct 16, 2024

NextUI Version

@nextui-org/[email protected]

Describe the bug

DatePicker component unexpectedly closes when value property changes from null to a CalendarDateTime.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

import { toCalendarDateTime } from '@internationalized/date'

<DatePicker
  value={state} //const [ state, setState ] = useState(null)
  onChange={e => setState(toCalendarDateTime(e))}
/>

I had to do this workaround because there is no way to display the time fields without a default value (feat?)

Expected behavior

DatePicker doesnt closes and time fields appears.

Screenshots or Videos

Particulita

Operating System Version

Windows

Browser

Chrome

@wingkwong
Copy link
Member

any reason to use CalendarDateTime? You may try

const [value, setValue] = React.useState<DateValue>();
// ...
<DatePicker value={value} onChange={setValue} />

@lilkimo
Copy link
Author

lilkimo commented Oct 16, 2024

@wingkwong because the component only displays time fields when a CalendarDateTime or ZonedDateTime value/defaultValue is provided (As shown in the docs).
Unfortunately your solution doesnt work for me because the project im working on is JS only.

This is not related to this issue but a showTimeFields prop might be a nice feature.

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