fix(view,place): the boards view pads clear of the phone's navbar

The panel had an inset for this; the calendar never did. Its root filled the
leaf, and Obsidian's phone navbar floats over a leaf rather than shortening
it, so the scroll container ran to the bottom of the screen and the last row
of the list sat under the bar - unreachable.

`lib/inset.ts` is the same pure measurement the panel plugin grew, with the
same tests: the deeper of navbar and keyboard, never their sum, and a bar that
sits beside the view covers nothing of it. The view re-measures by frame until
it holds still and writes `--bcal-inset-bottom`.

`viewport()` subtracts the bar too, so anchored panels and the quick look are
placed against what is actually reachable instead of ending under it.
This commit is contained in:
hh committed 2026-09-05 01:05:14 +02:00
1 parent f7ccd21d7b
commit f980abcc1d
6 files changed
+267 -3

No files matched your search

+39 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { onScreen, place, roomFor } from "../src/lib/place";
import { onScreen, place, roomFor, viewport } from "../src/lib/place";
import type { Box } from "../src/lib/place";
const VIEW = { width: 1280, height: 800 };
@@ -95,3 +95,41 @@ describe("roomFor", () => {
expect(roomFor({ width: 390, height: 60 })).toBeGreaterThan(100);
});
});
// Obsidian's phone navbar is not part of the visual viewport - it floats over
// it - so a panel sized to the viewport still ends up underneath it.
describe("viewport minus the floating navbar", () => {
function fakeWin(navbarTop: number | null, height = 780): Window {
const bar = {
getBoundingClientRect: () => ({
top: navbarTop ?? 0,
bottom: height,
height: height - (navbarTop ?? 0),
left: 0,
right: 390,
}),
offsetParent: {},
};
return {
innerWidth: 390,
innerHeight: height,
visualViewport: { width: 390, height, offsetTop: 0, offsetLeft: 0 },
document: {
querySelector: (selector: string) =>
selector === ".mobile-navbar" && navbarTop !== null ? bar : null,
},
} as unknown as Window;
}
it("takes the navbar off the bottom", () => {
expect(viewport(fakeWin(724)).height).toBe(724);
});
it("leaves the height alone with no navbar in the way", () => {
expect(viewport(fakeWin(null)).height).toBe(780);
});
it("still leaves a usable strip if a bar somehow covers everything", () => {
expect(viewport(fakeWin(0)).height).toBeGreaterThanOrEqual(120);
});
});