saas-js / saas-ui

The React component library for startups, built with Chakra UI.
https://saas-ui.dev
MIT License
1.32k stars 128 forks source link

DateInput is not updating the value of the DatePickerDialog #206

Closed tuantvu closed 7 months ago

tuantvu commented 7 months ago

Description

When using the DateInput or DatePickerInput with a DatePickerDialog, on change of the DateInput or DatePickerInput does not update the value in the DatePickerDialog. This can be recreate-able in the Saas-UI live demo. Consistently keeping the values in sync between the two components feels more user friendly.

Link to Reproduction

https://saas-ui.dev/docs/components/date-time/date-input

Steps to reproduce

  1. Go to any live demo example
  2. Edit the input date field to another month or year
  3. Open the date picker dialog using the calendar icon
  4. The date picker dialog will still show the current month and year

Saas UI Version

0.31.1

Chakra UI Version

2.2.0

Browser

Chrome 121.0.6167.184

Operating System

Additional Information

Screenshot 2024-02-19 at 1 57 29 PM

linear[bot] commented 7 months ago

SUI-412 DateInput is not updating the value of the DatePickerDialog

tuantvu commented 7 months ago

I stumbled upon a workaround. I don't know why, but when I extracted the DatePickerDialog into a private component, the DatePickerInput and DatePickerDialog stays in sync. Using the DatePickerDialog or wrapping it with one layer of Box doesn't work. See example below.

const MyComponent = () => {
    // private component
    const Dialog = () => (
      <DatePickerDialog>
        <DatePickerCalendar />
      </DatePickerDialog>
    )

    return (
      <DatePicker
        placement="bottom"
        granularity="day"
      >

          <DatePickerInput />

        {/* WORKS*/}
        <Dialog />

        {/* DOES NOT WORK
          <DatePickerDialog>
            <DatePickerCalendar />
          </DatePickerDialog>
        */}

         {/* ALSO DOES NOT WORK
         <Box>
          <DatePickerDialog>
            <DatePickerCalendar />
          </DatePickerDialog>
        </Box> */}
      </DatePicker>
    )
}
Pagebakers commented 7 months ago

Interesting that this fixes it, thanks for the info. I'm going to investigate this now.

Pagebakers commented 7 months ago

The value is actually in sync, but the calendar doesn't open on the correct month.

Pagebakers commented 7 months ago

@tuantvu it seems like a limitation of react aria calendar. Found a fix, will release it later this week.

Pagebakers commented 7 months ago

This was released in 0.12.23