[scheduler] Recalculate DayTimeGrid hasScroll on container resize#22780
Merged
noraleonte merged 1 commit intoJun 12, 2026
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
Author
|
@rita-codes @zannager Kindly have a review when you get time. Thanks! |
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
DayTimeGrid hasScroll on container resize
noraleonte
approved these changes
Jun 12, 2026
noraleonte
left a comment
Contributor
There was a problem hiding this comment.
Thank you for your contribution! 🎉 The fix looks good to me 👌
mbrookes
pushed a commit
to mbrookes/mui-x
that referenced
this pull request
Jun 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #22758
Summary
DayTimeGrid(the time grid shared by the Week and Day views) reserves ascrollbar-gutterplaceholder in the all-day header and the last day-header cell so those columns stay aligned with the scrollable body below. That placeholder is toggled by ahasScrollflag, surfaced asdata-has-scroll.hasScrollwas only recomputed when the events changed. It never recomputed when the container resized, so a resize that crossed the body's vertical-overflow threshold without an event change lefthasScrollstale, and the all-day header columns drifted from the body columns by about one scrollbar width.Root cause
hasScrollwas measured in a single layout effect keyed only onoccurrencesMap, with no resize signal:So a window resize, a side-panel toggle, or any height change that did not also change the events was ignored.
Fix
Extract the measurement into a stable callback and drive it from both signals: the existing layout effect (events) and a
ResizeObserveron the body (size). This reusesuseResizeObserverfrom@mui/x-internals, which the siblingMonthViewalready uses, and mirrors the existing find-and-measure idiom inGridMultiselectMeasurer.The layout effect is intentionally kept rather than replaced. A
ResizeObserveron the body alone is not guaranteed to catch the all-day-events-grow case in every consumer layout (it only shrinks the body when the container is height-capped), so keeping theoccurrencesMaprecompute guarantees that path stays covered. The fix is local toDayTimeGridand benefits both the Week and Day views, since both render this component. No new dependency is added.Testing
Added a browser test at
packages/x-scheduler/src/internals/components/day-time-grid/tests/DayTimeGrid.test.tsx. It is gated withdescribe.skipIf(isJSDOM)becausehasScrolldepends on real layout, which jsdom does not implement.The test renders the week view in a tall host so the body does not overflow (
data-has-scrollabsent), then shrinks the container through direct DOM mutation so the body overflows without a React re-render, and assertsdata-has-scrollappears. Resizing through the DOM rather than a React re-render is deliberate: a rerender re-runs the component and masks the bug, so it would not actually exercise the resize path.Verified:
expected ... to have an attribute 'data-has-scroll'), proving it catches the regression.pnpm --filter "@mui/x-scheduler" run typescript,pnpm eslint, and the fullpnpm test:unit --project "x-scheduler" --run jsdomsuite all pass with no regressions.Run it with:
pnpm test:browser --project "x-scheduler" --run DayTimeGridOut of scope
While in this file I noticed two pre-existing, unrelated issues that I deliberately did not change to keep this PR scoped: a malformed selector
&:not[data-has-scroll]atDayTimeGrid.tsx:79(should be&:not([data-has-scroll])), and a dead--has-scroll: 1custom property atDayTimeGrid.tsx:38. These can be addressed separately.Changelog
@mui/x-schedulerDayTimeGridso the all-day header scrollbar gutter recalculates on container resize, keeping the header columns aligned with the scrollable body.Checklist