diff --git a/src/components/Schedule/DayView.tsx b/src/components/Schedule/DayView.tsx index 8d5514f..b55ae7f 100644 --- a/src/components/Schedule/DayView.tsx +++ b/src/components/Schedule/DayView.tsx @@ -12,6 +12,7 @@ import { formatMonthTitle, } from 'components/Schedule/shared'; import type { + ScheduleInitialScrollTime, ScheduleTimeGridOverlapBehavior, ScheduleView, ScheduleViewComponentProps, @@ -30,6 +31,12 @@ export interface ScheduleDayViewOptions { * @default 100 */ hourHeight?: number; + /** + * Where the grid scrolls when it mounts, when it scrolls vertically (as with + * `height="fill"`). Later renders, including paging, keep the user's scroll. + * By default the grid opens at its first hour. + */ + initialScrollTime?: ScheduleInitialScrollTime; /** * Exclusive ending hour shown in the day grid (1-24). * @default 24 @@ -71,6 +78,7 @@ function ScheduleDayView({ days={days} height={height} hourHeight={options.hourHeight} + initialScrollTime={options.initialScrollTime} maxHour={options.maxHour} minHour={options.minHour} overlapBehavior={options.overlapBehavior} @@ -85,6 +93,7 @@ function ScheduleDayView({ export function createScheduleDayView({ allDayEventLimit = 3, hourHeight = 100, + initialScrollTime, maxHour = 24, minHour = 0, overlapBehavior = 'sideBySide', @@ -111,6 +120,7 @@ export function createScheduleDayView({ options: { allDayEventLimit, hourHeight, + initialScrollTime, maxHour, minHour, overlapBehavior, diff --git a/src/components/Schedule/Schedule.browser.test.tsx b/src/components/Schedule/Schedule.browser.test.tsx index d1ffbc9..d546524 100644 --- a/src/components/Schedule/Schedule.browser.test.tsx +++ b/src/components/Schedule/Schedule.browser.test.tsx @@ -4,6 +4,10 @@ import {beforeEach, describe, expect, it, vi} from 'vitest'; import {Schedule} from 'components/Schedule/Schedule'; import {createScheduleWeeklyView} from 'components/Schedule/WeeklyView'; import {useScheduleEventCreatePlugin} from 'components/Schedule/plugins/EventCreatePlugin'; +import type { + Instant, + ScheduleInitialScrollTime, +} from 'components/Schedule/types'; import {Temporal} from 'internal/temporal'; // Real-layout placement tests for the create popover, reproducing a tall @@ -105,3 +109,96 @@ describe('Schedule create popover placement (browser)', () => { }, ); }); + +// A full-day grid in a short frame, so every case has room to scroll. +function ScrollingWeek({ + initialScrollTime, + viewDate, +}: { + initialScrollTime: ScheduleInitialScrollTime; + viewDate: Instant; +}) { + return ( +