[@mantine/schedule] MonthView: option to start the grid from the week that holds the last day of the previous month #9456
s-asoft
started this conversation in
Feature requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
What
Add a way to choose which week
MonthViewstarts on. Today the grid always starts on the week that holds the 1st of the month (getStartOfWeek(startOfMonth)inutils/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):consistentWeeks)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:
getMonthDaysis internal;MonthViewcalls 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,firstDayOfWeekandconsistentWeekscannot express "start one week earlier only in these months".Proposed API
Smallest change: one boolean on
MonthView(and passed throughSchedule'smonthViewProps):startFromPreviousMonthDay?: boolean— defaultfalse, so nothing changes for current users.trueandwithOutsideDaysistrue, the grid starts on the week that holds the last day of the previous month.withOutsideDaysisfalse, it is ignored (a row with no visible days makes no sense).Inside,
getMonthDaysgets the matching option, andgetMonthRangeuses the same value so the event range matches the grid:YearViewandMobileMonthViewkeep 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/schedule9.8.1 withpnpm patch. The patch adds afromDayZeroflag togetMonthDays;MonthViewpassesfromDayZero: withOutsideDaysandgetMonthRangepassesfromDayZero: 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.All reactions