circuit-ui
circuit-ui copied to clipboard
Date components don't respect moment.js locale
Describe the bug
When multiple moment.js instances are used in an application, Circuit UI components that rely on moment.js do not respect the current locale.
Steps to reproduce
Steps to reproduce the behavior:
- Install
moment.js
in an application that's also using Circuit UI - Use a Circuit UI component that uses moment.js (e.g. Calendar)
- Set the current locale using
moment.locale
- Observe that the Circuit UI component still uses the default locale to display date information
Expected behavior
Circuit UI components should display date information formatted for the current locale set via moment.locale
.
Specifications
- Version: v2+
- Browser: all
- OS: all
Additional context
✅ The issue can be resolved by pinning the moment.js version in the application to 2.29.0
to match the version that's included with Circuit UI.
We should move moment.js to peer dependencies or replace it entirely. Both of these changes would be a breaking change.
Are you planning to keep moment.js in this library ?
No. moment.js
is a sub-dependency of react-dates
on which our date picker components are based. There's an open issue to refresh the date picker components (https://github.com/sumup-oss/circuit-ui/issues/537#issue-557192595) with the following requirement:
- replace
react-dates
with a library that supports TypeScript, tree-shaking, and doesn't depend onmoment.js