onesine / react-tailwindcss-datepicker

Modern date range picker component for React using Tailwind 3 and dayjs. Alternative to Litepie Datepicker.
https://react-tailwindcss-datepicker.vercel.app/
MIT License
552 stars 169 forks source link

Value not displaying #217

Open mschipperheyn opened 1 year ago

mschipperheyn commented 1 year ago

I have an issue where the datepicker itself seems to be working fine, it is displaying the calendar dropdown, etc. But never a selected value, not does it seem to be setting the value

Not even when I try this

return (
<Datepicker
          inputName="my-field
          value={{
            startDate:'2023-01-01',
            endDate: null
          }}
          useRange={false}
          asSingle
          onChange={handleChange}
        />
)

or

return (
<Datepicker
          inputName="my-field
          value={{
            startDate: new Date('2023-01-01'),
            endDate: null
          }}
          useRange={false}
          asSingle
          onChange={handleChange}
        />
)

I'm using a monorepo with remix. This component is a separate ui package. I started wondering if this could be some kind of context related issue

mschipperheyn commented 1 year ago

The reason for my confusions is that if endDate is null, a value I considered irrelevant in an asSingle scenario, there is no inputValue change. What I would suggest is add a warning here, bc it's a little counter intuitive behaviour.

romdim commented 8 months ago

I just figured out the same. The startDate value was not shown unless there was also an endDate (with the same value).