Skip to content

[@mantine/schedule] MonthView: option to start the grid from the week that holds the last day of the previous month #9445

Closed

Description

@s-asoft

What

Add a way to choose which week MonthView starts on. Today the grid always starts on the week that holds the 1st of the month (getStartOfWeek(startOfMonth) in utils/get-month-days/get-month-days.ts). We need it to start on the week that holds the day before the 1st ("day 0", the last day of the previous month).

The two rules give the same grid in most months. They differ only when the 1st falls on the first day of the week. Example, firstDayOfWeek={0} (Sunday), November 2026 (1 Nov is a Sunday):

Rule First cell Last cell (with consistentWeeks)
Current (week of the 1st) Sun 1 Nov Sat 12 Dec
Requested (week of day 0) Sun 25 Oct Sat 5 Dec

Why

We are porting an app from another framework to Mantine Schedule. That framework's month view computes its first cell with firstVisibleMonthDay, which starts from the week of day 0. So in those months the other framework always shows one row of the previous month at the top. Users of the existing app expect that layout, and saved screenshots, docs and training use it. With Mantine, the same month opens with no previous-month row, and the grid ends one week later.

There is no way to get this today from outside the component:

  • getMonthDays is internal; MonthView calls it directly with { month, firstDayOfWeek, consistentWeeks }.
  • getMonthRange (used for the visible range / events) also calls it, so the event range must change together with the grid.
  • date, firstDayOfWeek and consistentWeeks cannot express "start one week earlier only in these months".

Proposed API

Smallest change: one boolean on MonthView (and passed through Schedule's monthViewProps):

<MonthView date="2026-11-15" firstDayOfWeek={0} startFromPreviousMonthDay />
  • startFromPreviousMonthDay?: boolean — default false, so nothing changes for current users.
  • When true and withOutsideDays is true, the grid starts on the week that holds the last day of the previous month.
  • When withOutsideDays is false, it is ignored (a row with no visible days makes no sense).

Inside, getMonthDays gets the matching option, and getMonthRange uses the same value so the event range matches the grid:

// utils/get-month-days/get-month-days.ts
interface GetMonthDaysInput {
  month: AnyDateValue;
  firstDayOfWeek: DayOfWeek | undefined;
  consistentWeeks: boolean | undefined;
  startFromPreviousMonthDay?: boolean;
}

let date = dayjs(
  getStartOfWeek({
    date: startFromPreviousMonthDay ? start.subtract(1, 'day').format('YYYY-MM-DD') : startOfMonth,
    firstDayOfWeek,
  })
);

YearView and MobileMonthView keep their current behaviour (they do not pass the option).

A more general alternative, if preferred: getFirstGridDay?: (month: DateStringValue, firstDayOfWeek: DayOfWeek) => DateStringValue. The boolean covers our case and is simpler to document.

Related

Other requests to customise the month view grid: #8885 (hide weekends or specific weekdays in the month view) and #9081 (custom date range for ResourcesMonthView). This one is narrower: it changes only the first week of the grid.

How we do it now

We patch @mantine/schedule 9.8.1 with pnpm patch. The patch adds a fromDayZero flag to getMonthDays; MonthView passes fromDayZero: withOutsideDays and getMonthRange passes fromDayZero: true. It is about 10 changed lines in the ESM and CJS builds. We are happy to open a PR with the source change, tests and a demo if this direction is acceptable.

Activity

  1. locked and limited conversation to collaborators on Nov 20, 2026
  2. converted this issue into a discussion #9456 on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions