[pickers] Remove PickersDay and promote PickerDay2 as a replacement#21739
[pickers] Remove PickersDay and promote PickerDay2 as a replacement#21739michelengelen wants to merge 95 commits intomui:masterfrom
PickersDay and promote PickerDay2 as a replacement#21739Conversation
Signed-off-by: michel <jsnerdic@gmail.com>
|
Deploy preview: https://deploy-preview-21739--material-ui-x.netlify.app/ Updated pages:
Bundle size report
|
Signed-off-by: michel <jsnerdic@gmail.com>
LukasTy
left a comment
There was a problem hiding this comment.
A couple of additional notes:
-
nitpick: this doesn't look like a pro (DateRangePicker) package change in any way
-
Have you considered the change for PickersDay2 as well?
- Side note: WDYT, @noraleonte, is that component ready to replace the OG one?
It's a breaking change, because of styling requirements. So, now, or wait another ~year 🙈
- Side note: WDYT, @noraleonte, is that component ready to replace the OG one?
-
Now that I have seen this, I can not unsee it. 🙈
How come the day number is not vertically aligned within the button? 😂Screen.Recording.2026-03-19.at.16.40.40.mov
@noraleonte, have you noticed this? Do you have a better fix for this than
line-height: 1? 🤔
Yes, you are right ... I just took this since it was reported from that component in the bug-issue. Will change that.
No, thanks for pointing me to that though.
If possible in any way I would like to include any breaking changes now, ideally with this release. So if there is a decision to be made I would go for it now.
🫣
|
display: block for PickersDay component styledisplay: block for PickersDay component style
@LukasTy I would love to use text-box, but it seems we are a bit early for this, since it is not yet widely adopted |
I think it might be, but seems a bit short notice to include it in this release 🙈 I'm not worried about the component not being ready, it's more that it's a breaking change, comes with a migration guide + we need to check all the demos are still working properly (customization ones especially) 🙈
I haven't noticed it but now it's bugging me. Present in |
|
So, to conclude, I see two paths: Lazy
Proper bad-ass 😆
In both cases, I'd urge setting Does that sound about right, @noraleonte? I leave the decision to @michelengelen. |
|
Yes, that's a pretty accurate summary 👌 |
…ponding imports alongside Signed-off-by: michel <jsnerdic@gmail.com>
…picker' into bugfix/21615-misaligned-days-in-picker
Signed-off-by: michel <jsnerdic@gmail.com>
Signed-off-by: michel <jsnerdic@gmail.com>
Signed-off-by: michel <jsnerdic@gmail.com>
Signed-off-by: michel <jsnerdic@gmail.com>
display: block for PickersDay component stylePickersDay and promote PickerDay2 as a replacement
…ligned-days-in-picker
Signed-off-by: michel <jsnerdic@gmail.com>
Signed-off-by: michel <jsnerdic@gmail.com>
… day width with week number cell
…ault behavior logic
Co-authored-by: Lukas Tyla <llukas.tyla@gmail.com> Signed-off-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com>
…picker' into bugfix/21615-misaligned-days-in-picker
…y visibility styling options
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
flaviendelangle
left a comment
There was a problem hiding this comment.
A few remaining points and we are good to go
Code Review: #21739
PR: [PickersDay] Remove PickersDay and promote PickerDay2 as a replacement
Author: Michel Engelen (@michelengelen)
Labels: breaking change, scope: pickers, type: enhancement
Stats: +3,375 / -3,356 across 163 files
Fixes: #21615 (misalignment when theme typography.caption has a display definition)
Rating: 4/5
Overview
This PR consolidates the date picker day components by:
- Removing
PickersDay(the legacy component with multi-element DOM structure) - Renaming
PickerDay2→PickerDay(promoting the simplified single-element implementation) - Renaming
DateRangePickerDay2→DateRangePickerDay(rewriting the range day as a singleButtonBasewith pseudo-elements) - Removing
disableMarginprop from both components - Providing 5 codemods for automated migration
- Comprehensive migration documentation in the v8→v9 guide
Strengths
Excellent migration story
- 5 separate codemods covering every facet of the breaking change:
rename-pickers-day,rename-picker-day-2,remove-picker-day-2,rename-picker-classes,remove-disable-margin - Each codemod has
actual.spec.tsx/expected.spec.tsxtest fixtures and a proper test file - The
remove-picker-day-2codemod is particularly thorough — it handles both inlineslots={{ day: PickerDay2 }}and variable-basedconst slots = { day: PickerDay2 }patterns, with dead-code cleanup
Well-documented breaking changes
- The migration guide clearly explains what changed, why, and how to update for each breaking area (component renames, class renames,
disableMarginremoval,data-testidchanges, selection behavior changes) - Code examples are provided for before/after
Simplified DOM structure
- Moving from multi-element to single-element + pseudo-elements (
::before/::after) is a meaningful improvement for theming and reduces DOM complexity - The
display: flex+lineHeight: 1fix directly addresses the reported alignment bug (#21615)
Good test coverage
- New test for drag events targeting nested day elements, which validates the new single-element structure works with drag-and-drop
Issues & Suggestions
1. Bug in overridesResolver (Medium severity)
In PickerDay.tsx, the overridesResolver has what appears to be a bug carried over from PickerDay2:
ownerState.isDayOutsideMonth && styles.dayOutsideMonth,The original PickerDay2 had:
!ownerState.isDayOutsideMonth && styles.dayOutsideMonth,The diff shows this was changed from !ownerState.isDayOutsideMonth to ownerState.isDayOutsideMonth. This looks intentional and correct — the old negation was likely a bug in PickerDay2 since the style should apply when the day is outside the month.
However, confirm this was intentional as the semantic difference is significant.
2. onDaySelect null check added without explanation
// Before
if (!disabled) {
onDaySelect(day);
}
// After
if (!disabled && onDaySelect) {
onDaySelect(day);
}onDaySelect is a required prop in the type definition. Adding a runtime null check for a required prop suggests either:
- The types should be updated to make it optional, or
- There's a specific edge case where it can be undefined despite the types
This should be clarified or the types should be aligned.
3. preset-safe codemod ordering
The preset-safe runs all codemods in sequence. The order matters here — rename-picker-day-2 should run before remove-picker-day-2 since the latter looks for PickerDay2 identifiers that may have already been renamed. Verify the execution order is correct.
4. Missing test coverage for PickerDay itself
The PR adds a test for DateRangeCalendar drag behavior with nested elements, but there are no new tests for the renamed/refactored PickerDay component itself (e.g., testing the new firstVisibleCell/lastVisibleCell classes, the filler cell div rendering, or the display: flex fix that motivated this PR).
5. Theme component name backwards compatibility
The theme component name changes from MuiPickersDay to MuiPickerDay and from MuiDateRangePickerDay2 to MuiDateRangePickerDay. Users with theme overrides targeting the old names will silently stop working. The migration docs cover this, but the codemods don't appear to handle theme configuration objects — they focus on imports and JSX usage. Consider documenting this limitation in the codemod section.
6. DateRangePickerDay rewrite is large
The DateRangePickerDay.tsx went from ~250 lines wrapping PickersDay to ~416 lines as a standalone ButtonBase component. While this is architecturally sound (no longer depends on the old PickersDay), the complete rewrite in a single PR makes it harder to review for subtle behavioral regressions. The pseudo-element approach for selection/preview highlighting is well-structured though.
Minor Observations
- The
getDensePickerThemefiles correctly updateMuiDateRangePickerDay2→MuiDateRangePickerDay - API page JSON files are properly regenerated
- Translation files are updated consistently
- The
PickersPlaygroundcomponent correctly removesPickerDay2/DateRangePickerDay2references WeekPickerdemo properly migrates fromPickersDaytoPickerDayand removesdisableMargin
Summary
A well-executed breaking change with strong migration tooling. The architectural improvement (single-element day components with pseudo-elements) is sound and directly fixes the reported alignment bug. The main areas for improvement are around test coverage for the new PickerDay component and ensuring the codemod execution order is correct in the preset-safe bundle. The migration documentation is thorough and actionable.
PickersDay and promote PickerDay2 as a replacementPickersDay and promote PickerDay2 as a replacement
This prevents misalignment when the theme used by the user has a
displaydefinition in theirtypography.captiontheme object.Fixes #21615