circuit-ui icon indicating copy to clipboard operation
circuit-ui copied to clipboard

Date components don't respect moment.js locale

Open connor-baer opened this issue 3 years ago • 2 comments

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:

  1. Install moment.js in an application that's also using Circuit UI
  2. Use a Circuit UI component that uses moment.js (e.g. Calendar)
  3. Set the current locale using moment.locale
  4. 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.

connor-baer avatar Sep 28 '20 09:09 connor-baer

Are you planning to keep moment.js in this library ?

long-lazuli avatar Jun 28 '22 08:06 long-lazuli

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 on moment.js

connor-baer avatar Jun 28 '22 08:06 connor-baer