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): anchor the ghost popover to its selection shading again
Elian Doran6f838b44498a
diff --git a/apps/client/src/widgets/collections/calendar/GhostPopover.tsx b/apps/client/src/widgets/collections/calendar/GhostPopover.tsxindex 1afe3a73dc..c438fbdcae 100644--- a/apps/client/src/widgets/collections/calendar/GhostPopover.tsx+++ b/apps/client/src/widgets/collections/calendar/GhostPopover.tsx@@ -165,13 +165,16 @@ export default function GhostPopover({ draft, anchor, container, onCommit, onCan/*** Where the ghost stands: beside the range's own shading, read back off the grid. FullCalendar- * draws the selection as one `.fc-highlight` per row it crosses, so the piece under the mouseup is- * the one pointed at — where the drag ended is where the eye is — falling back to the last piece- * drawn, and to the bare point where no shading is on the grid at all. Read afresh on every- * reposition (see Popover), so the ghost follows the shading through scrolls and redraws.+ * draws the selection as one piece per row it crosses, so the piece under the mouseup is the one+ * pointed at — where the drag ended is where the eye is — falling back to the last piece drawn, and+ * to the bare point where no shading is on the grid at all. Read afresh on every reposition (see+ * Popover), so the ghost follows the shading through scrolls and redraws.+ *+ * The pieces answer to the name the calendar gives them through `highlightClass`, FullCalendar+ * having no class of its own left to go by (see the calendar view).*/function ghostAnchorRect(container: HTMLElement | null, point: AnchorPoint | null): DOMRect {- const highlights = container?.querySelectorAll<HTMLElement>(".fc-highlight");+ const highlights = container?.querySelectorAll<HTMLElement>(".calendar-highlight");if (highlights?.length) {let pick: HTMLElement | undefined;diff --git a/apps/client/src/widgets/collections/calendar/index.css b/apps/client/src/widgets/collections/calendar/index.cssindex 377b00693d..f2edbe5134 100644--- a/apps/client/src/widgets/collections/calendar/index.css+++ b/apps/client/src/widgets/collections/calendar/index.css@@ -106,6 +106,12 @@filter: var(--calendar-coll-event-hover-filter, none);}+/* The shading a dragged range stands in, named by us rather than left to the theme's hashed class+ so the ghost can anchor to it; the colour is still Forma's, off the palette. */+.calendar-view .calendar-highlight {+ background-color: var(--fc-forma-highlight);+}+/* The note's icon, leading its title on the chip (see eventContent). */.calendar-view .calendar-event-icon {margin-inline-end: .25em;diff --git a/apps/client/src/widgets/collections/calendar/index.tsx b/apps/client/src/widgets/collections/calendar/index.tsxindex 5db5956ec5..9b150cd75e 100644--- a/apps/client/src/widgets/collections/calendar/index.tsx+++ b/apps/client/src/widgets/collections/calendar/index.tsx@@ -337,6 +337,10 @@ export default function CalendarView({ note, noteIds }: ViewModeProps<CalendarVi// already begun by then, and FullCalendar knows not to clear what the same press// has just made.unselectCancel=".calendar-ghost-popover, .calendar-ghost-sheet"+ // Named by us so the ghost can find the shading it stands beside, v7 drawing it+ // under a hashed class otherwise (see ghostAnchorRect in GhostPopover). The look+ // is Forma's own, which is one declaration off the palette.+ highlightClass="calendar-highlight"eventClick={onEventClick}// The event the popover stands for is marked as such, and asks for no hover// preview while it does: the popover beside it already says everything the