Skip to content

[bug]: Calendar month dropdown uses browser locale instead of respecting locale prop #7844

@abnerlumis

Description

@abnerlumis

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

  1. Use the Calendar component with a specific locale prop (e.g., locale={es})
  2. Open the month dropdown
  3. 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

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