Skip to content

Commit

Permalink
fix(DateField): not showing any value in range mode (#4533)
Browse files Browse the repository at this point in the history
* fix(DateField): not showing any value in range mode

* fix: feedbacks
  • Loading branch information
matthprost authored Dec 3, 2024
1 parent 4b3ffd5 commit af519f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/purple-mice-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ultraviolet/form": patch
---

Fix `<DateField />` when having ranged value and nothing is displayed in the popover
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ import { DateField, Form } from '../..'
import { useForm } from '../../..'
import { mockErrors } from '../../../mocks'

const yesterdayDate = new Date(Date.now() - 60 * 60 * 24 * 1000)
const todayDate = new Date()
const INITIAL_FORM_VALUES = {
date: [yesterdayDate, todayDate],
}

export default {
component: DateField,
decorators: [
ChildStory => {
const methods = useForm({
defaultValues: INITIAL_FORM_VALUES,
mode: 'onChange',
})
const {
Expand Down
2 changes: 1 addition & 1 deletion packages/form/src/components/DateField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const DateField = <
name={field.name}
label={label}
placeholder={placeholder}
value={field.value}
value={Array.isArray(field.value) ? undefined : field.value}
format={
format ||
(value => {
Expand Down

0 comments on commit af519f1

Please sign in to comment.