nextui-org / nextui

🚀 Beautiful, fast and modern React UI library.
https://nextui.org
MIT License
21.94k stars 1.53k forks source link

[BUG] - DateRangePicker error message not using NextUIProvider Locale #3693

Closed SimonGodefroid closed 1 month ago

SimonGodefroid commented 2 months ago

NextUI Version

2.4.2

Describe the bug

Set the locale in the NextUIProvider

  <NextUIProvider locale='en-GB'>{children}</NextUIProvider>

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

Set the locale in the NextUIProvider

  <NextUIProvider locale='en-GB'>{children}</NextUIProvider>

Consume the DateRangePicker component

...
// from the docs
const min = today(getLocalTimeZone());
...
<DateRangePicker
  label="Start date - End date"
  minValue={min}
/>

Expected behavior

The error message should respect the provided's locale format. ATM I receive Value must be 8/29/2024 or later. I expect instead Value must be 29/08/2024 or later.

Screenshots or Videos

image

Operating System Version

macOs

Browser

Chrome

linear[bot] commented 2 months ago

ENG-1301 [BUG] - DateRangePicker error message not using NextUIProvider Locale

macci001 commented 2 months ago

Seems like validation messages which includes the date needs to be modified by the next-ui. The validation messages obtained from the react-aria are created by the browser, hence the custom locale would not work here. The date in error message will contain the locale of the browser.

I am not sure if there is any hack for this to get the validation message according to the custom locale.

I am putting in a PR to fix this.

ryo-manba commented 1 month ago

Thanks for the issue. If you'd like to set the validation message using a locale other than the browser's, please handle it using the errorMessage prop. You can refer to the following for more details: https://github.com/nextui-org/nextui/pull/3694#issuecomment-2387218249.