react-day-picker icon indicating copy to clipboard operation
react-day-picker copied to clipboard

Explicitly provide resolved locale for all functions which need it

Open daveallie opened this issue 4 months ago • 5 comments

What's Changed

locale is optionally user defined as a prop to DayPicker and should fallback to en-US (the default for DayPicker) when none is supplied by the user. There were several places where this default was not respected, and instead props.locale was used (which can be undefined).

This PR addresses the above problem by explicitly requiring locale as a non-optional argument everywhere it's used, similar to how dateLib is passed around.

This resolves #2509 (related discussion #2511) in where if the client application used date-fns and had a locale set through dateFns.setDefaultOptions, then the internal calls to date-fns within DayPicker would use this client defined default (instead of the en-US default) in the cases where props.locale was being used (namely useCalendar).

Once we cross the threshold into DayPicker, we should always be using a resolved locale object to ensure consistency of rendered dates across components.

Type of Change

  • [x] Bug fix
  • [ ] New feature
  • [ ] Breaking change
  • [ ] Documentation update

Additional Notes

Fixes #2509 Related #2511

daveallie avatar Oct 08 '24 00:10 daveallie