-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
In the Persian / Hijri / Jalali Calendar section of the calendar component docs, when captionLayout is set to "dropdown", the month is not displayed correctly—it still shows Gregorian months.
There are two ways to fix this:
- Change the default formatMonthDropdown inside calendar.tsx.
- Pass a custom month formatter when instantiating the component:
<Calendar
mode="single"
selected={date}
onSelect={handleDateSelect}
autoFocus
captionLayout="dropdown"
formatters={{
formatMonthDropdown: date =>
date.toLocaleString('fa-IR', { month: 'short' }),
}}
/>;
This will display the months in Persian (Jalali) correctly when using the dropdown layout.
Affected component/components
Calendar, Date Picker
How to reproduce
- Update the calendar component in
calendar.tsx
to use theDayPicker
component fromreact-day-picker/persian
instead ofreact-day-picker
.
// Before
import { DayPicker } from 'react-day-picker';
// After
import { DayPicker } from 'react-day-picker/persian';
- Create a Calendar component instance with captionLayout="dropdown".
<Calendar
mode="single"
selected={date}
onSelect={handleDateSelect}
autoFocus
captionLayout="dropdown"
/>;
-
Use the component with the default settings (without a custom formatMonthDropdown).
-
Open the month dropdown in the calendar.
-
Observe that the month names are displayed in Gregorian format instead of Persian / Jalali.
Codesandbox/StackBlitz link
No response
Logs
System Info
not relevant
Before submitting
- I've made research efforts and searched the documentation
- I've searched for existing issues
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working