equinor / design-system

The Equinor design system
MIT License
118 stars 64 forks source link

Datepicker min/max value validation errors do not follow the selected locale #3638

Open estoksam opened 3 weeks ago

estoksam commented 3 weeks ago

We want to use the DatePicker's min and max value to help the user select an appropriate date, but have encountered a blocker. It turns out the DatePicker produces Norwegian text in our English language application.

Regardless of the locale setting, the DatePicker displays the validation error in Norwegian. image

Steps to reproduce the bug Steps to reproduce for min-value, but max-value behaves the same

  1. Create a DatePicker with min value and locale set to anything other than Norwegian, e.g. "en"
  2. Use the keyboard to select a date earlier than the min value

To quickly reproduce it, go to https://storybook.eds.equinor.com/?path=/story/inputs-dates-datepicker--with-min-and-max-value&locale:en (notice that "en" is selected), and follow the steps. You'll see image (American date format and Norwegian validation error)

Expected behavior

It's expected that the validation error is displayed in the selected language, just as the calendar's months and days use the selected locale's language.

Instead, the validation error is in Norwegian. I don't know why Norwegian is selected in particular, but it's not unreasonable in my case.

Specifications

Other info I think I've traced the problem back to Adobe's code in https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/form/src/useFormValidationState.ts, so I don't think your code is to blame directly. In any case, something isn't using the specified locale.

estoksam commented 3 weeks ago

I added a minor update about Edge also being affected.