-
Notifications
You must be signed in to change notification settings - Fork 832
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
Wrong value of isValid() when using DE #1895
Comments
@TomekStaszkiewicz Thanks for the detailed reproduction. Did you have a chance to look at why it behaves wrongly like this? |
I have simplified the reproduction down to: import "dayjs/locale/de";
import dayjs from "dayjs";
import * as React from "react";
import DayJsAdapter from "@material-ui/pickers/adapter/dayjs";
const util = new DayJsAdapter({ locale: "de" });
console.log("1", util.parse("Januar 2020", "MMMM YYYY")); // KO
console.log("2", dayjs("Januar 2020", "MMMM YYYY", "de")); // OK
console.log("3", dayjs("Januar 2020", "MMMM YYYY")); // KO
export default function App() {
return <div />;
} https://codesandbox.io/s/dreamy-goldstine-xty48?file=/src/App.jsx The problem is in https://github.com/dmtrKovalenko/date-io/blob/400e9f60f0990995c374978b3be4867aecea539c/packages/dayjs/src/dayjs-utils.ts#L105 We should be doing: public parse(value: any, format: any) {
if (value === "") {
return null;
}
- return this.dayjs(value, format);
+ return this.dayjs(value, format, this.locale);
} @TomekStaszkiewicz Do you want to work on a pull request :)? |
Could it be worth adding a test case for? It seems that we should. |
Environment
Steps to reproduce
Open code sandbox link: https://codesandbox.io/s/billowing-snowflake-gfgts?file=/package.json
Use English, then edit it using input(NOT THE POPOVER)
When it's an invalid date, the textfield is shown as red
if you change it back to correct date it turns green.
Change to de and do the same things
But when it's valid again, it remains red.
If you check the console, you will see that the isValid() returns false for the correct date.
Expected behavior
isValid() returning true for correct date
Actual behavior
What is important is that this bug occurs only when changing the date by typing in the date. It does not occur when you change the date by clicking on the popover.
The text was updated successfully, but these errors were encountered: