Repository navigation
[scheduler] Fix the drag and drop of the day grid across DST transitions and speed up its preview - #23964
Conversation
…ons and speed up its preview Move the drop target of the day cells, the grabbed day of the day grid events and the placeholder selectors to day numbers and wall-clock times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
…ansition skips Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…holders `usePlaceholderInDay()` and `isCreatingInDayCell()` receive the processed day of the cell and read its timestamp and key instead of the adapter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…simplify the drop target - `CalendarGridDayEvent` passes the grabbed day as a day number, which the drop target compares with the day of the cell, instead of an adapter value it converted back. - One branch moves the day grid and time grid events, and `moveToDay()` moves the resized edges. - A resize onto the other edge's day uses `getStartOfDayMs()` and `getEndOfDayMs()`, and `getProcessedDayNumber()` reads the day of a processed date. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Duplicates the helpers of mui#23961 instead of keeping its own: the offset-based `buildTemporalPlainDate()` and `toLocalDayNumber()`, with the same lines so that whichever lands second merges cleanly. The drop target moves dates onto plain dates, and the placeholders keep day numbers for the days of the cells. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The grabbed day and the span of the placeholder read plain dates. Only the selectors that run for every cell keep day numbers. - Moving an event by days no longer throws past December 31st, 9999, which the month grid shows. - The resize branches compare the dates once, and external events are handled before reading the day of the cell. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… day Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…day grid PR `useEventOccurrencesWithDayGridPosition()` counts the dates of a span from the timestamps of its end and of the day, with `toLocalDayNumber()`, in the same lines as mui#23961, instead of building a plain date for each day. Whichever PR lands second has nothing to merge there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… date Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dates after December 31st, 9999 aren't supported, so `addDaysOnWallClock()` moves the date with `add()` instead of building it from its day number, and the test of a move past the last supported day goes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
…of the store The day event, the day placeholder and the placeholder selectors read the day of a processed date from its timestamp and the display timezone of the store, instead of reading its value through the adapter. The day cell drop target reuses the timezone of the cell for the dragged event. The selector tests build their days in UTC, so their store now displays UTC, like a real store builds its days in its display timezone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I found no bugs: I compared the placeholder selectors, moves, resizes and timed → all-day moves with master across system and display timezones around DST, and every difference is one of the listed behavior changes. A few things on the tests and the description: 🟡 No test has a display day that differs from the UTC day. Replacing the display timezone with 🟡 The resize branches aren't pinned. Nothing resizes onto the day of the other edge or past it, nothing resizes the start across DST, and nothing lands a time that a DST transition skips: moving the gap backward instead of forward keeps the tests green. ℹ️ The description says that whichever of this PR and #23961 lands second has nothing to merge, but they conflict in ℹ️ The master column of the benchmark can't come from the committed file: it passes processed days to the placeholder selectors, which take adapter values on master, so no cell matches there. With adapter values on master, I get about the same speedup (≈2× and ≈75×). |
This PR moves the drag and drop of the Event Calendar's day grid to plain dates and wall-clock times, after the recurring events in #23943. The day grid is the Month view and the all-day row of the Week and Day views: moving and resizing events across days, moving a timed event into the all-day row, and the preview drawn while dragging. It's independent of #23961, #23962 and #23963. The public API doesn't change.
Changes
useDayCellDropTarget()reads the days as plain dates in the display timezone and moves the dates on the wall clock, keeping their time of day. A move shifts them by whole days, and a resize moves them to the plain date of the cell withmoveToPlainDate(). A time that a DST transition skips moves forward by the length of the gap, and a repeated one resolves to its first instant, like the wall times of [scheduler] Fix recurring events across timezones and DST transitions #23943.getDraggedDay()inCalendarGridDayEventcounts the dates an event covers in its row, like the cells it's drawn on. It reads the first and last dates of the event from their timestamps, in the display timezone of the store. The drag data carries the grabbed day as a plain date instead of an adapter value.useEventOccurrencesWithDayGridPosition()counts the cells of an event in dates too, with the same lines as [scheduler] Speed up the day grid and fix day lists across DST transitions #23961, so that the event is drawn over the dates the drag counts.useCalendarGridPlaceholderInDay()compare timestamps and day numbers instead of callingisSameDay(),isWithinRange(),isBefore()andisAfter(). They run for every cell on every move of the pointer, where creating a plain date per cell made them twice as slow. The cells pass their processed day toisCreatingInDayCell()andusePlaceholderInDay(), which read itstimestampandkey, with the display timezone of the store, instead of the adapter, and reuse it for a creation placeholder instead of processing it again.drag-utils.tsgetsmoveToPlainDate()andaddDaysOnWallClock(), which move adapter values on the wall clock withPlainDate.buildTemporalPlainDate()reads the offsets of the timezone instead of the getters of the adapter, andtoLocalDayNumber()joinsplain-date-utils, with the same lines as [scheduler] Speed up the day grid and fix day lists across DST transitions #23961, so that whichever lands second has nothing to merge.Behavior changes
getDraggedDay()counted the full days from its start time, so an event from Monday 10:00 to Wednesday 09:00 lasted 2 days for it while it's drawn over 3 cells. Dropping its Wednesday part on Thursday moved it to Wednesday–Friday. It moves to Tuesday–Thursday now.differenceInDays()could miss a day: dragging an event onto that day from a later one could move it one day short, or not at all. An event ending before 01:00 on a later day was also drawn one cell short: from March 9th, 2026 at 12:00 to March 10th at 00:30 in Havana, it covered March 9th only. It covers both days now.Benchmarks
Mean times of
pnpm bench:jsdominpackages/x-scheduler-internalswithTZ=UTC: the placeholder selectors of the 42 cells of a month view, as they run on each move of the pointer while dragging a 3-day event. Master and this PR ran in turn, 5 times each, and each column is the median of their runs.In a named timezone, each
isSameDay()built newTZDatevalues, which took over 2 ms of each frame.Bundle size
Measured from source with esbuild, minified, with third-party packages external and without the error minifier, gzip level 9.
event-calendarevent-calendar-premiumevent-timeline-premiumThe community package now bundles
PlainDate, which accounts for the 5 kB. The premium packages already did.Adapter usage
Counted like in #23943. The references go from 523 to 511, and
getMonthis gone. The PR removes 37 references to calendar math and comparisons. Reading the timestamps and timezones of the values adds 25getTime()andgetTimezone()references, which read a field of theTZDate. ThegetTime()ones read the dates of the placeholder and the bounds of the rows and columns, which have no processed version. The processed days and events carry no timezone, so their dates come from their timestamps and the display timezone of the store.isSameDayaddDaysisAfterstartOfDayisBeforedifferenceInDaysendOfDayaddMilliseconds,isWithinRangegetDate,getYear,getMonthgetTimegetTimezoneValidation
pnpm test:unit --project "x-scheduler*" --run: 3,791 passed, andpnpm test:browser --project "x-scheduler-internals*" --run: 2,417 passed. The Month view popover test that times out under load passes alone. The new tests of the timed multi-day event and of the repeated hour on a New York system fail on master.After merging master, the RTL drag test of the Month view passes in the browser, and the tests that timed out in a full run on a loaded machine pass alone.
A randomized harness, not committed, compared the new code with master's on 5,000 random cases under each of 8 system timezones (UTC, New York, Paris, Lord Howe, Havana, Kolkata, Apia and Santiago), across 10 display timezones and around their DST transitions: the 4 placeholder selectors, the moves and resizes of the day cells, the moves of timed events into the day grid and the grabbed day. Every difference falls into one of the behavior changes above. It found the same on the final version of this PR.
Review rounds with Codex and the base-ui-review skill:
/simplifypass then passed the grabbed day as a day number and merged the branches of the drop target that move events. The grabbed day and the days of the drop target then became plain dates./simplifypass kept day numbers only in the selectors that run for every cell, and compared the dates once per resize.TypeScript, ESLint and Prettier pass.
I have followed (at least) the PR section of the contributing guide.
🤖 Generated with Claude Code