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] - DateRangePicker throws an error when I clear any time data #3388

Closed
uigywnkiub opened this issue Jul 1, 2024 · 4 comments · Fixed by #3409
Closed

[BUG] - DateRangePicker throws an error when I clear any time data #3388

uigywnkiub opened this issue Jul 1, 2024 · 4 comments · Fixed by #3409
Assignees
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working

Comments

@uigywnkiub
Copy link

NextUI Version

2.4.2

Describe the bug

DateRangePicker throws an error when I clear any time data. Select any field value and delete numbers to zero.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Select any number field in DateRangePicker. 2. Clear the field.

Expected behavior

I guess it must be 0 or an empty field without throwing an error.

Screenshots or Videos

My code

type TProps = {
  selectedDate: RangeValue<DateValue>
  onDateSelection: (dateRange: RangeValue<DateValue>) => void
}

function MonthPicker({ selectedDate, onDateSelection }: TProps) {
  return (
    <div className='mb-6 flex justify-between'>
      <div>
        <DateRangePicker
          label='Select a date range'
          labelPlacement='outside'
          value={selectedDate}
          onChange={onDateSelection}
        />
      </div>
    </div>
  )
}

export default memo(MonthPicker)

Video

Screen.Recording.2024-07-01.at.23.13.31.mov

On your site also error.

image

Operating System Version

  • OS: macOS

Browser

Chrome

Copy link

linear bot commented Jul 1, 2024

@ShrinidhiUpadhyaya
Copy link
Contributor

When you clear the field the value becomes null. You could make this change const startYear = startDate && format(startDate, "y")

@ShrinidhiUpadhyaya
Copy link
Contributor

I could reproduce the error in stories and in docs (https://nextui.org/docs/components/date-range-picker#presets).

@wingkwong can i work on this and create a PR?

@wingkwong
Copy link
Member

@ShrinidhiUpadhyaya Assigned. Feel free to ping me if you have any questions.

ShrinidhiUpadhyaya pushed a commit to ShrinidhiUpadhyaya/nextui that referenced this issue Jul 3, 2024
@wingkwong wingkwong added 🐛 Type: Bug Something isn't working 📦 Scope : Components Related to the components labels Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants