sumup-oss / circuit-ui

SumUp's design system for the web
https://circuit.sumup.com
Apache License 2.0
917 stars 130 forks source link

Date components don't respect moment.js locale #674

Closed connor-baer closed 5 months ago

connor-baer commented 4 years ago

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

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.

long-lazuli commented 2 years ago

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

connor-baer commented 2 years ago

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 commented 5 months ago

moment.js was made an optional peer dependency in v7 (https://github.com/sumup-oss/circuit-ui/pull/2094).