Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pickers] Fields don't work with AdapterDateFns and zhCN locale #14800

Open
arjaym-dev opened this issue Oct 2, 2024 · 3 comments
Open

[pickers] Fields don't work with AdapterDateFns and zhCN locale #14800

arjaym-dev opened this issue Oct 2, 2024 · 3 comments
Labels
component: pickers This is the name of the generic UI component, not the React module! external dependency Blocked by external dependency, we can’t do anything about it l10n localization support: commercial Support request from paid users support: pro standard Support request from a Pro standard plan user. https://mui.com/legal/technical-support-sla/

Comments

@arjaym-dev
Copy link

arjaym-dev commented Oct 2, 2024

The problem in depth

Hello, first here's the live demo for the said issues https://stackblitz.com/edit/react-knfbz7?file=Demo.js

Step to reproduce:
First Scenario you must use the enUS as the adaterLocale
PS: the format of field is in this type 'MMM d HH:mm' the step below you must change/update value is the HH:mm for you to see the concern issues

  • Then after that try making changes on the SingleInputDateTimeRangeField then look for the logs
  • The logs shows [dateValue, dateValue] if you update the firstInputDate
  • The logs shows [dateValue, dateValue] if you update the endInputDate

Second Scenario you must change the enUS to zhCN as the adapterLocale

  • Then after that try making changes on the SingleInputDateTimeRangeField then look for the logs
  • The logs shows [null, dateValue] if you update the firstInputDate
  • The logs shows [dateValue, null] if you update the endInputDate

Expected result:
On second scenario if the locale is using zhCN it should not null either value for first or end inputDate. it should be same result with the first scenario

Note: Only the zhCN return null but when using other locale it works perfectly

import { enUS, zhCN, de, enGB } from 'date-fns/locale'

Your environment

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: SingleInputDateTimeRangeField, locale
Order ID: 70493

@arjaym-dev arjaym-dev added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels Oct 2, 2024
@github-actions github-actions bot added component: pickers This is the name of the generic UI component, not the React module! support: pro standard Support request from a Pro standard plan user. https://mui.com/legal/technical-support-sla/ labels Oct 2, 2024
@michelengelen
Copy link
Member

Ok, I did manage to find a reproduction for this.
Apparently putting in any month with a leading 1 is not working (10, 11, 12, and even 1). 10 seems to be the worst as it looks like this will result in an incorrect value which in turn resolves in null.

Screen.Recording.2024-10-02.at.14.40.13.mov

@flaviendelangle you did build the single input field ... could you have a look at this?

@michelengelen michelengelen added bug 🐛 Something doesn't work l10n localization and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 2, 2024
@michelengelen michelengelen changed the title [question] SingleInputDateTimeRangeField having issues with locale switching to zhCN [pickers] SingleInputDateTimeRangeField having issues with locale switching to zhCN Oct 2, 2024
@flaviendelangle
Copy link
Member

Hey thanks for your detailed example.

The zhCN locale is enable to parse dates with this format when the month is October 😬
The problem seems to be the MMM token (MMMM is also broken), you can try the format MM d which works and MMM d which is broken.

Here a simple reproduction case

This looks like the bug repported in this issue: date-fns/date-fns#3256

I would suggest you to have a look and it and if you have the time to propose a fix.

@flaviendelangle flaviendelangle added external dependency Blocked by external dependency, we can’t do anything about it and removed bug 🐛 Something doesn't work labels Oct 2, 2024
@flaviendelangle flaviendelangle changed the title [pickers] SingleInputDateTimeRangeField having issues with locale switching to zhCN [pickers] Fields don't work with AdapterDateFns and zhCN locale Oct 2, 2024
@arjaym-dev
Copy link
Author

After checking out related issues, seems likes on date-fns date-fns/date-fns#3256 that still not able/possible to parse when month is October and any date & locale zhCN. Still now i know what's happening behind why its returning null.

Thank you for that workaround of using MM d format. @flaviendelangle @michelengelen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! external dependency Blocked by external dependency, we can’t do anything about it l10n localization support: commercial Support request from paid users support: pro standard Support request from a Pro standard plan user. https://mui.com/legal/technical-support-sla/
Projects
None yet
Development

No branches or pull requests

3 participants