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

[Date Picker] Behavior improvements and bug fixes #9486

Open
Devessier opened this issue Jan 9, 2025 · 0 comments
Open

[Date Picker] Behavior improvements and bug fixes #9486

Devessier opened this issue Jan 9, 2025 · 0 comments
Assignees

Comments

@Devessier
Copy link
Contributor

Devessier commented Jan 9, 2025

Here is a list of identified flaws:

  • The selected date randomly changes
  • The Month and Year selects do not change the selected date
  • Clicking on the left and right arrows shouldn't change the selected date but only show the previous or next month
  • Selecting a month or a year shouldn't change the selected date but change the displayed month

These bugs also affect FormDateTimeFieldInput and FormDateFieldInput.

Bug: The selected date randomly changes

CleanShot.2025-01-09.at.13.07.44.mp4

This is likely a timezone or date truncation issue. We would have to dive deeper.

Bug: The Month and Year selects do not work

CleanShot.2025-01-09.at.13.09.13.mp4

As @muraliSingh7 explained, a click-outside listener closes the date inputs before a month or year is selected. See twentyhq/core-team-issues#88.

Improvement: The selects and buttons in <AbsoluteDatePickerHeader /> should only update the displayed month, not the selected date

CleanShot.2025-01-09.at.13.10.14.mp4

See how Notion behaves:

CleanShot.2025-01-09.at.15.19.05.mp4

The <AbsoluteDatePickerHeader /> component takes onAddMonth and onSubtractMonth properties.

The library react-datepicker library supports doing that. See the code snippet below. We would have to have two separate dates. A "temporary" date, provided by ReactDatePicker and updated with the changeYear and increaseMonth functions; and the "selected" date, which is the one currently stored in the backend and used as the input's value.

<ReactDatePicker
  renderCustomHeader={({
    date,
    changeYear,
    changeMonth,
    increaseMonth,
    decreaseMonth,
    prevMonthButtonDisabled,
    nextMonthButtonDisabled,
  }) =>
    isRelative ? (
      <RelativeDatePickerHeader
        direction={relativeDate?.direction ?? 'PAST'}
        amount={relativeDate?.amount}
        unit={relativeDate?.unit ?? 'DAY'}
        onChange={onRelativeDateChange}
      />
    ) : (
      <AbsoluteDatePickerHeader
        date={internalDate}
        temporaryDate={date}
        onChange={onChange}
        onChangeMonth={changeMonth}
        onChangeYear={changeYear}
        onAddMonth={increaseMonth}
        onSubtractMonth={decreaseMonth}
        prevMonthButtonDisabled={prevMonthButtonDisabled}
        nextMonthButtonDisabled={nextMonthButtonDisabled}
        isDateTimeInput={isDateTimeInput}
        timeZone={timeZone}
        hideInput={hideHeaderInput}
      />
    )
  }
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant