adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.87k stars 1.12k forks source link

Date won't select the day #5062

Closed sinafath closed 6 months ago

sinafath commented 1 year ago

Provide a general summary of the issue here

day selection won't work correct for Persian calendar

๐Ÿค” Expected Behavior?

If I select the fifth to seventh day of Mehr 1402 that range to be selected not another day

๐Ÿ˜ฏ Current Behavior

please select the fifth to seventh day of Mehr 1402 in this Codesandbox example that I used to replicate the bug. to do this you have to go next month and select fifth and seventh day of the next month. but what you see now is another range date has been selected

๐Ÿ’ Possible Solution

        function toPersianCalendar<T extends AnyCalendarDate>(date: T) {
       return toCalendar(date, new PersianCalendar());
      }
const [value,setValue] = useState()
    <DateRangePickerBase
     onChange{setValue}
        value={value?.start && value?.end &&{
          start: toPersianCalendar(field.value.start),
          end: toPersianCalendar(field.value.end),
        }} 
      />

๐Ÿ”ฆ Context

No response

๐Ÿ–ฅ๏ธ Steps to Reproduce

Codesandbox example

Version

"@internationalized/date": "3.0.0",
"react-aria": "3.21.0",
"react-stately": "3.19.0"

What browsers are you seeing the problem on?

Firefox, Chrome

If other, please specify.

No response

What operating system are you using?

windows

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

sinafath commented 1 year ago

I tested fifth to seventh day of every month it can't be selected

LFDanLu commented 1 year ago

Looks like the issue is specifically with any of the months ahead of the current date, any of the months before the current date don't exhibit this issue. Possibly related to https://github.com/adobe/react-spectrum/issues/3757#issuecomment-1446846517, where it was noted that the isSameDay helper util has problems comparing the persian dates with gregorian ones