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
feat(calendar): let a committed ghost simply go
Elian Doran4d791b384242
diff --git a/apps/client/src/widgets/collections/calendar/GhostPopover.tsx b/apps/client/src/widgets/collections/calendar/GhostPopover.tsxindex ea3354b1b5..fa9831d7f5 100644--- a/apps/client/src/widgets/collections/calendar/GhostPopover.tsx+++ b/apps/client/src/widgets/collections/calendar/GhostPopover.tsx@@ -14,13 +14,14 @@ import { AnchorPoint, EventDraft } from "./selection";/*** The ghost: the form an event is decided in before its note exists. It asks for the one thing the* drag did not say — the name — and writes out the one thing it did; everything else an event can- * hold waits for the note, one commit away. Dismissed — Escape, the close button, a press anywhere- * else — the draft simply evaporates: nothing was created.+ * hold waits for the note, a click on its chip away. Dismissed — Escape, the close button, a press+ * anywhere else — the draft simply evaporates: nothing was created.** A desktop stands it beside the range that called for it, a draft being born of a place: the form* appears where the eye already is, and the grid does not reflow under the very range just dragged.* A phone gets the sheet the app raises its dialogs as, there being no room beside anything (see- * EventPopover, which divides itself the same way). The event surface takes over at the commit.+ * EventPopover, which divides itself the same way). Committed, it simply goes: the calendar is left+ * as it was found, with the new chip on it (see commitDraft in index.tsx).** Committing with the title blank is allowed and meaningful: the note is then named by the* calendar's own `#titleTemplate` where one is set (see getNewNoteTitle in trilium-core), whichdiff --git a/apps/client/src/widgets/collections/calendar/index.tsx b/apps/client/src/widgets/collections/calendar/index.tsxindex 88c4567a18..8dd1bdf3dd 100644--- a/apps/client/src/widgets/collections/calendar/index.tsx+++ b/apps/client/src/widgets/collections/calendar/index.tsx@@ -147,25 +147,31 @@ export default function CalendarView({ note, noteIds }: ViewModeProps<CalendarViconst editingProps = useEditing(note, isEditable, isCalendarRoot, parentComponent?.componentId,(draft, anchor) => setSelection({ draft, anchor }));- // Turns the standing ghost into the note: created only now, at the commit, and — where the- // reader typed nothing — named by the calendar's own titleTemplate, the very thing the old- // title prompt used to override. The event popover takes over from the ghost, opening on the- // new note at the ghost's own anchor — the chip itself has yet to be drawn.+ /**+ * Turns the standing ghost into the note: created only now, at the commit, and — where the+ * reader typed nothing — named by the calendar's own titleTemplate, the very thing the old+ * title prompt used to override.+ *+ * The calendar is then left as it was found, the new chip standing on it. Nothing is opened on+ * the note: the ghost asked for everything a quick addition needs, and a surface raised over+ * the very stretch of grid just worked in would have to be dismissed before the next event+ * could be dragged out beside it. Whatever else the note may hold is a click on its chip away+ * — which is where such a surface would have opened anyway.+ */const commitDraft = useCallback(async (title: string) => {if (!selection || !("draft" in selection)) return;- const created = await newEvent(note, {+ await newEvent(note, {title: title.trim() || undefined,...selection.draft,componentId: parentComponent?.componentId});- if (created) {- // The range has become an event and its shading has nothing left to stand for; the- // chip takes its place. Said here because no press said it: committing is a key or a- // button within the ghost, and the ghost is exempt from clearing the shading.- calendarRef.current?.unselect();- setSelection({ noteId: created.noteId, anchor: selection.anchor });- }++ // The range has become an event and its shading has nothing left to stand for; the chip+ // takes its place. Said here because no press said it: committing is a key or a button+ // within the ghost, and the ghost is exempt from clearing the shading.+ calendarRef.current?.unselect();+ setSelection(null);}, [ selection, note, parentComponent?.componentId ]);/**