Skip to content

[pickers] Flag the first and last visible day cell across year boundaries#22981

Merged
LukasTy merged 2 commits into
mui:masterfrom
Anexus5919:fix/day-calendar-visible-cell-year-boundary
Jun 29, 2026
Merged

[pickers] Flag the first and last visible day cell across year boundaries#22981
LukasTy merged 2 commits into
mui:masterfrom
Anexus5919:fix/day-calendar-visible-cell-year-boundary

Conversation

@Anexus5919

@Anexus5919 Anexus5919 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Fixes a bug where the first/last visible cell of the calendar day grid was never flagged when it fell in a different year than the displayed month.

In DayCalendar, isFirstVisibleCell / isLastVisibleCell computed the current-month anchor with adapter.setMonth(day, currentMonthNumber), which keeps day's year. For an outside-month cell in a different year (for example 2023-12-31 as the first cell of a January 2024 grid), the anchor became January 2023, so the genuine first cell was never flagged. The same happened for December grids whose last visible cell falls in the next January.

The fix anchors on currentMonth (already available via parentProps), which carries the correct year. Behavior is unchanged for months that do not cross a year boundary.

These flags feed the PickerDay isFirstVisibleCell / isLastVisibleCell props and the MuiDateRangePickerDay-firstVisibleCell / -lastVisibleCell classes. No built-in style consumes them, so there is no default visual change, but consumer or theme overrides targeting those classes are affected.

Closes #22978

Change summary

Fixed the first/last visible cell of the calendar day grid not being flagged at year boundaries.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@Anexus5919

Copy link
Copy Markdown
Contributor Author

@michelengelen @LukasTy Kindly have a review on this pr. Thanks!

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-22981--material-ui-x.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers ▼-13B(-0.01%) ▼-1B(0.00%)
@mui/x-date-pickers-pro ▼-13B(0.00%) ▼-4B(-0.01%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@LukasTy LukasTy added type: bug It doesn't behave as expected. scope: pickers Changes related to the date/time pickers. labels Jun 29, 2026

@LukasTy LukasTy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your contribution is much appreciated! 🙏

@LukasTy
LukasTy merged commit 9908ee8 into mui:master Jun 29, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: pickers Changes related to the date/time pickers. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[pickers] Cross-year outside-month days are never flagged as the first/last visible cell

2 participants