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

[DateCalendar] Calendar view reverts to wrong year when using shouldDisableDate #15428

Closed
ponm-dnv opened this issue Nov 15, 2024 · 2 comments
Closed
Labels
bug 🐛 Something doesn't work component: pickers This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information

Comments

@ponm-dnv
Copy link

ponm-dnv commented Nov 15, 2024

Steps to reproduce

Steps:

  1. Open this link to live example: https://codesandbox.io/p/sandbox/dark-water-g2pzsw?file=%2Fsrc%2FDemo.tsx%3A19%2C39
  2. use header to select year: 2025
  3. select month: September

Current behavior

Notice that the date is not what you selected - reverts to September 2022, or the last year that you've viewed with non-disabled dates

Expected behavior

The calendar should stay on the month/year that you selected

Context

This only happens when selecting a date within a large range of disabled dates, e.g. selecting Sept 2025 when all of 2025 is disabled. Adding one non-disabled date in 2025 solves it for that year, but the problem continues for other years in the future.

Your environment

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

Search keywords: shouldDisableDate, monthCalendar

@ponm-dnv ponm-dnv added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 15, 2024
@github-actions github-actions bot added the component: pickers This is the name of the generic UI component, not the React module! label Nov 15, 2024
@LukasTy
Copy link
Member

LukasTy commented Nov 15, 2024

@ponm-dnv how would you expect this scenario to work? 🤔
The whole 2025 year is disabled from shouldDisableDate, but to disable the year on YearCalendar you should use shouldDisableYear.
We are not calling shouldDisableDate on month or year calendars for performance reasons, you can imagine that calling shouldDisableDate ~365 times does not sound performant. 🙈

@LukasTy LukasTy added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 15, 2024
Copy link

The issue has been inactive for 7 days and has been automatically closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: pickers This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information
Projects
None yet
Development

No branches or pull requests

2 participants