Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(calendar): widen the event popover and hold it to the window
Elian Doranb44f7de51ab2
diff --git a/apps/client/src/widgets/collections/calendar/EventPopover.css b/apps/client/src/widgets/collections/calendar/EventPopover.cssindex af1294fef2..56e7349dcb 100644--- a/apps/client/src/widgets/collections/calendar/EventPopover.css+++ b/apps/client/src/widgets/collections/calendar/EventPopover.css@@ -1,7 +1,12 @@.calendar-event-popover {- width: 380px;- /* A fixed-width card as tall as its event needs, up to what the viewport can spare; what it- holds scrolls within it (see the body below). */+ /* One width whatever event it stands for, and as tall as that event needs; what it holds+ scrolls within it (see the body below). Both are held to what the window can spare: the card+ is anchored beside a chip rather than laid over the page, and Popper answers a card too big+ for the room by shifting it into the viewport rather than by narrowing it (see the+ preventOverflow modifier in Popover.tsx) — so a width the window cannot take would hang off+ the edge instead of being given back.+ The width must agree with `MAX_ANCHOR_WIDTH` in selection.ts. */+ width: min(480px, calc(100vw - 4rem));max-height: min(640px, 85vh);.calendar-event-popover-inner {diff --git a/apps/client/src/widgets/collections/calendar/selection.spec.ts b/apps/client/src/widgets/collections/calendar/selection.spec.tsindex 47f1692ed0..b01df94b91 100644--- a/apps/client/src/widgets/collections/calendar/selection.spec.ts+++ b/apps/client/src/widgets/collections/calendar/selection.spec.ts@@ -15,7 +15,9 @@ describe("narrowAnchorRect", () => {it("leaves a piece that can be stood beside as it stands", () => {expect(narrowAnchorRect(chip, { x: 720, y: 205 })).toBe(chip);// Right up to the width of the widest card, which still leaves the grid's own room.- expect(narrowAnchorRect(new DOMRect(700, 200, 380, 20), { x: 720, y: 205 })).toEqual(new DOMRect(700, 200, 380, 20));+ expect(narrowAnchorRect(new DOMRect(700, 200, 480, 20), { x: 720, y: 205 })).toEqual(new DOMRect(700, 200, 480, 20));+ // A hair over it is narrowed, the card no longer having room to stand beside the piece.+ expect(narrowAnchorRect(new DOMRect(700, 200, 481, 20), { x: 720, y: 205 })).toEqual(new DOMRect(720, 200, 0, 20));});it("narrows a piece too wide to be stood beside to the press within it", () => {diff --git a/apps/client/src/widgets/collections/calendar/selection.ts b/apps/client/src/widgets/collections/calendar/selection.tsindex 149f84496f..1a035b86eb 100644--- a/apps/client/src/widgets/collections/calendar/selection.ts+++ b/apps/client/src/widgets/collections/calendar/selection.ts@@ -62,5 +62,8 @@ export function narrowAnchorRect(rect: DOMRect, point: AnchorPoint | null): DOMR}/** How wide a piece may be and still be stood beside: the width of the widest card the calendar- * anchors — the event popover's 380px, the ghost's own being narrower (see their CSS). */-const MAX_ANCHOR_WIDTH = 380;+ * anchors — the event popover's 480px, the ghost's own being narrower (see their CSS). The+ * popover's full width rather than the lesser one a narrow window leaves it: a piece that wide on+ * a window that narrow fills it, and the card is then placed by the viewport whatever anchor it is+ * handed. */+const MAX_ANCHOR_WIDTH = 480;