-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
The Calendar component's month dropdown uses the browser's default locale instead of respecting the passed locale
prop for month formatting.
Expected Behavior
Month names should be formatted according to the explicitly passed locale prop, regardless of browser language settings.
Actual Behavior
Month names are displayed based on the browser's default locale, ignoring the locale prop passed to the component.
Additional Context
The issue is in the formatMonthDropdown
function in calendar component:
formatters={{
formatMonthDropdown: (date) => date.toLocaleString('default', { month: 'short' }),
...formatters,
}}
The 'default'
parameter causes toLocaleString()
to use the browser's locale instead of the component's locale prop. It should be:
formatters={{
formatMonthDropdown: (date) => date.toLocaleString(props?.locale?.code || 'default', { month: 'short' }),
...formatters,
}}
Affected component/components
Calendar
How to reproduce
- Use the Calendar component with a specific locale prop (e.g.,
locale={es}
) - Open the month dropdown
- Observe that month names are displayed according to browser language instead of the passed locale
Codesandbox/StackBlitz link
https://codesandbox.io/p/github/abnerlumis/calendar-locale-bug-demo/main?import=true
System Info
macOS 15.5
Chrome Version 138.0.7204.101 (Official Build) (arm64)
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