Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Calendar: the first hour in view shows whole, and Year keeps its months together

Yashwanth Kamireddifb560a55e340
diff --git a/.uiverify/calendar-look.mjs b/.uiverify/calendar-look.mjs
new file mode 100644
index 0000000..f391b39
--- /dev/null
+++ b/.uiverify/calendar-look.mjs
@@ -0,0 +1,18 @@
+// Every Calendar view at a given size, in the chosen engine, for looking at.
+// ENGINE=webkit node .uiverify/calendar-look.mjs <out-dir> [width] [height]
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub } from "./stub.mjs";
+const [out, w = "1920", h = "1040"] = process.argv.slice(2);
+const b = await engine.launch();
+const ctx = await b.newContext({ viewport: { width: +w, height: +h }, colorScheme: "dark" });
+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null,
+ calendarFixture: true, notesFixture: true, contactsFixture: true, driveFixture: true, remindersFixture: true });
+const p = await ctx.newPage();
+await p.goto("http://localhost:4173", { waitUntil: "networkidle" });
+await p.locator(".nav-item", { hasText: "Calendar" }).click();
+for (const v of ["Day", "Week", "Month", "Year"]) {
+ await p.getByRole("button", { name: v, exact: true }).click();
+ await p.waitForTimeout(400);
+ await p.screenshot({ path: `${out}/cal-${v.toLowerCase()}.png` });
+}
+await b.close();
diff --git a/.uiverify/calendar.mjs b/.uiverify/calendar.mjs
index a84f81a..8438cf8 100644
--- a/.uiverify/calendar.mjs
+++ b/.uiverify/calendar.mjs
@@ -157,5 +157,37 @@ ok(/Sep/.test(title) && /Oct/.test(title), `a week across two months is named fo
"the popover stayed open after saving");
}
+// In the morning, at the size of a full-screen window: the week opens scrolled to just
+// before now, which puts an hour line at the very top — where its label was cut in half —
+// and a tall window is where Year spread its months apart.
+{
+ const tall = await ctx.newPage();
+ await tall.setViewportSize({ width: 1920, height: 1040 });
+ await tall.clock.setFixedTime(new Date(2026, 8, 29, 8, 30));
+ await tall.goto("http://localhost:4173", { waitUntil: "networkidle" });
+ await tall.getByRole("button", { name: "Week", exact: true }).click();
+ await tall.waitForTimeout(400);
+ const first = await tall.evaluate(() => {
+ const scroll = document.querySelector(".cx-scroll").getBoundingClientRect();
+ const labels = [...document.querySelectorAll(".cx-hour-labels span:not(.cx-now-label)")]
+ .map((s) => ({ text: s.textContent, top: s.getBoundingClientRect().top, bottom: s.getBoundingClientRect().bottom }))
+ .filter((l) => l.bottom > scroll.top);
+ return { label: labels[0], edge: scroll.top };
+ });
+ ok(first.label && first.label.top >= first.edge - 0.5, `the first hour in view is shown whole [${first.label?.text}]`,
+ `the first hour in view is cut: ${JSON.stringify(first)}`);
+
+ await tall.getByRole("button", { name: "Year", exact: true }).click();
+ await tall.waitForTimeout(250);
+ const gap = await tall.evaluate(() => {
+ // The days drawn, not the boxes around them: a stretched row stretches its boxes too.
+ const months = [...document.querySelectorAll(".cal-mini")];
+ const firstRowBottom = Math.max(...months.slice(0, 4).map((m) => m.querySelector(".cx-minimonth-grid").getBoundingClientRect().bottom));
+ return Math.min(...months.slice(4, 8).map((m) => m.querySelector("h2").getBoundingClientRect().top)) - firstRowBottom;
+ });
+ ok(gap <= 40, `Year's rows of months sit together [${gap.toFixed(0)}px apart]`, `Year's rows are ${gap.toFixed(0)}px apart`);
+ await tall.close();
+}
+
await b.close();
process.exitCode = failures === 0 ? 0 : 1;
diff --git a/src/screens/calendar/CalendarView.tsx b/src/screens/calendar/CalendarView.tsx
index e8bcbb5..f4b7ad3 100644
--- a/src/screens/calendar/CalendarView.tsx
+++ b/src/screens/calendar/CalendarView.tsx
@@ -831,7 +831,8 @@ function TimeGrid({
if (!el) return;
const showsToday = days.some((d) => sameDay(d, new Date()));
const hour = showsToday ? Math.max(0, new Date().getHours() - 2) : 7;
- el.scrollTop = hour * HOUR;
+ // A little above the hour, so its label — centred on the line — shows whole.
+ el.scrollTop = Math.max(0, hour * HOUR - 12);
// Only when the days change, never under someone's scrolling.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [days.map((d) => dayKey(d)).join()]);
diff --git a/src/styles/calendar.css b/src/styles/calendar.css
index 6edf75f..a983e26 100644
--- a/src/styles/calendar.css
+++ b/src/styles/calendar.css
@@ -466,6 +466,8 @@
.cal-year {
flex: 1;
display: grid;
+ /* Months packed at the top, as Calendar sets them — not spread to fill a tall window. */
+ align-content: start;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 22px 28px;
padding: 6px 18px 18px;