-
-
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
[DatePicker] shouldDisableDate
runs on all dates ever, not just visible ones before opening
#4705
Comments
+1, makes over 28k calls to that function on load. |
I'm having the same problem. |
@apenab @DanielAndrews43 @gl-aagostino This template could be a good starting point |
@flaviendelangle |
Without a reproduction case it's hard to to a diagnostic. |
@flaviendelangle Yes, I am trying to. Can we trust CodeSandbox, that it really uses downgraded dependencies, and not some leftovers? |
The version should be respected yes If you successfully reproduce it locally on an empty repo (with CRA or Next.JS for instance) I can clone it and test it on my machine as well. |
@flaviendelangle |
@flaviendelangle Latest versions of all |
@flaviendelangle Here is another codesandbox: https://codesandbox.io/s/date-and-time-pickers-forked-pqlc5j This actually uses your template. Changes are:
|
Hi @flaviendelangle |
This does not look like a bug. When no date is open, the component is looking for the closest valid date. You can verify this by returning. Here is an example with only one valid date (the 5 June 2020) And the component will loop over days until it find it. After that the If you have not available date, you should disable the component. If you know the first available date, setting it will prevent this search. @flaviendelangle I think you already fixed this in #6146 |
Yep, #6146 should close the problem 👍 |
@flaviendelangle when we can expect release? |
The fix has only been done on the v6 alpha. |
Duplicates
Latest version
Current behavior 😯
When using
DesktopDatePicker
it runsshouldDisableDate
on 100s of years of dates when first opening the modal. This delays the modal opening for several seconds. When switching between months, it only runsshouldDisableDate
on the visible dates, which looks correct.Screen.Recording.2022-01-31.at.12.15.24.PM.mov
Expected behavior 🤔
It should only run
shouldDisableDate
on the visible datesSteps to reproduce 🕹
Steps:
DesktopDatePicker
component withshouldDisableDate
propContext 🔦
We are creating invoicing software and only want dates to be selectable as a due date if they are on the correct billing day. This can be an expensive function for us to run if we need to pull additional data about exceptions. If it only runs on visible days there is almost no delay visible to the user, but if it's running on all historical dates then it ends up in 100s of network requests and slows down everything.
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: