-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[fields] Fix year editing on valid date #7834
[fields] Fix year editing on valid date #7834
Conversation
These are the results for the performance tests:
|
@@ -434,7 +434,24 @@ export const doesSectionHaveTrailingZeros = <TDate>( | |||
|
|||
// We can't use `changeSectionValueFormat`, because `utils.parse('1', 'YYYY')` returns `1971` instead of `1`. | |||
if (dateSectionName === 'year') { | |||
return utils.formatByString(utils.setYear(utils.date()!, 1), format).length > 1; | |||
const formatted2001 = utils.formatByString(utils.setYear(utils.date()!, 2001), format); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if that's the best approach
The challenge here is to know if we have trailing zeroes or not on the year.
But a year format can be 2-digit or 4-digit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this is a "necessary evil" to cover the different year formats adapters can have. 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this issue already known? It's a problem with next as well.
Screen.Recording.2023-02-06.at.15.09.28.mov
This behaviour seems somewhat strange. Is it supposed to work like that or is there some sort of a bug?
The first time we are entering date by inputting 02—only after 2
is pressed the value is presented.
While after that, even when deleting the whole date, any change in year section produces some sort of a value, and seemly wrong value? Because entering 0
in empty YY
section produces year 20
(2020) 🙈
P.S. With date-fns
adapter it seems to work correctly, while with dayjs
it is acting a bit strangely...
Screen.Recording.2023-02-06.at.15.12.55.mov
@@ -434,7 +434,24 @@ export const doesSectionHaveTrailingZeros = <TDate>( | |||
|
|||
// We can't use `changeSectionValueFormat`, because `utils.parse('1', 'YYYY')` returns `1971` instead of `1`. | |||
if (dateSectionName === 'year') { | |||
return utils.formatByString(utils.setYear(utils.date()!, 1), format).length > 1; | |||
const formatted2001 = utils.formatByString(utils.setYear(utils.date()!, 2001), format); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this is a "necessary evil" to cover the different year formats adapters can have. 🙈
If I understand the problem correctly: EDIT: Fixed by #7855 |
No description provided.