-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] Support AdapterLuxon
with throwOnInvalid = true
#11853
Comments
Hey @harry-peirse-jfc I can confirm this behavior (bug? 🤷🏼). |
This issue was introduced in v6.18.7. I believe this is the PR that introduced the issue #11566 |
This is easily reproduced by deleting for instance the month part (in the textfield) of a
Or entering a date in the textfield of a
|
@oscar-b @andbjer @harry-peirse-jfc I've created a draft PR with an experiment on how to handle this luxon setting. -"@mui/x-date-pickers": "^7.7.0"
+"@mui/x-date-pickers": "https://pkg.csb.dev/mui/mui-x/commit/064c2340/@mui/x-date-pickers" The main issue/question is how do we handle these "invalid" thrown dates as currently it seems more as a bug than a feature. Screen.Recording.2024-06-14.at.17.49.33.movWhat would you consider a proper behavior given the |
@LukasTy Thanks for looking into this. The whole situation with types in Luxon is.. not optimal. I don't know if you did more research, but here's some interesting tickets: Your PR seems to do the best with the situation at hand (only checked your video, haven't tried it myself yet), but losing the date on blur probably won't fly here. I'll probably have to investigate disabling |
@oscar-b thank you for sharing the discussion links. I'm not a fan of this behavior (throwOnInvalid) from the Picker Adapters perspective, because luxon is the only library/adapter, that I'm of, which has such option. Is the lack of support on the |
@LukasTy For our case, I'm reverting to not using |
AdapterLuxon
with throwOnInvalid = true
After a confused long search of why my build was suddenly encountering the below error, I luckily found this thread linked from the documentation page to understand why it's happening. I'll just paste the error here to help others find this thread from search engines:
|
Steps to reproduce
Link to live example
Steps:
Current behavior
It is standard practice in Luxon to write the following when invalid dates should throw errors:
In particular this type override tells Luxon that null won't be returned when parsing DateTimes.
Unfortuantely when this is set, it now breaks the AdapaterLuxon type checking when providing it to the LocalizationProvider. This worked without issues on @mui/x-date-pickers-pro version 6.18.4
Expected behavior
Providing AdapterLuxon to the LocalizationProvider with throwOnInvalid configured to
true
should not cause type errors.Context
No response
Your environment
npx @mui/envinfo
Search keywords: DateTime Typescript AdapterLuxon Error
Order ID: 60670
The text was updated successfully, but these errors were encountered: