Skip to content

[bug]: Month Dropdown Shows Gregorian Months in Persian / Jalali Calendar #8305

@sina-byn

Description

@sina-byn

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:

  1. Change the default formatMonthDropdown inside calendar.tsx.
  2. 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

  1. Update the calendar component in calendar.tsx to use the DayPicker component from react-day-picker/persian instead of react-day-picker.
// Before
import { DayPicker } from 'react-day-picker';

// After
import { DayPicker } from 'react-day-picker/persian';
  1. Create a Calendar component instance with captionLayout="dropdown".
<Calendar
  mode="single"
  selected={date}
  onSelect={handleDateSelect}
  autoFocus
  captionLayout="dropdown"
/>;
  1. Use the component with the default settings (without a custom formatMonthDropdown).

  2. Open the month dropdown in the calendar.

  3. 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

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions