Skip to content

Build your personal knowledge base with Trilium Notes

feat(geomap): let a marker's fields be filled in from its own pane

Elian Dorand92066ae9d61
diff --git a/apps/client/src/widgets/collections/geomap/DetailPane.css b/apps/client/src/widgets/collections/geomap/DetailPane.css
index 848b190812..254da4598f 100644
--- a/apps/client/src/widgets/collections/geomap/DetailPane.css
+++ b/apps/client/src/widgets/collections/geomap/DetailPane.css
@@ -61,8 +61,50 @@
/* Written for a note split, where the split hands it one; there is no split here, and an unset
`--max-content-width` would leave `max-width` invalid rather than absent. */
max-width: none;
- /* Without it a flex item refuses to shrink past its content, and a long note stops scrolling. */
- min-height: 0;
+ /* A floor rather than the 0 a flex item needs to scroll its own content: the fields above it are
+ as many as the note asks for, and without one they would squeeze the note out of the pane
+ instead of the body scrolling. Above the floor a long note still scrolls within itself. */
+ min-height: 120px;
+}
+
+/*
+ * The note's promoted fields, laid out for a third of the width they are written for: one field per
+ * line, each name over its own box rather than beside it. Side by side, a name of more than a word
+ * leaves nothing for the box, and every box starts at a different place down the column.
+ */
+.geo-map-container .geo-detail-pane .promoted-attributes-container {
+ flex-direction: column;
+ gap: 10px;
+ margin: 0;
+ /* The body of the pane is the one thing that scrolls; a scroller inside it would take the wheel
+ off whichever of the two the pointer happened to be over. */
+ max-height: none;
+}
+
+.geo-map-container .geo-detail-pane .promoted-attribute-cell {
+ flex-direction: column;
+ align-items: stretch;
+ margin: 0;
+
+ /* The gap after the name is the column's now, the name no longer standing beside the box. */
+ > .input-group,
+ > .promoted-attribute-values {
+ margin-inline-start: 0;
+ }
+}
+
+/* A flag is named after its own box, the checkbox and the words reading as the one sentence they
+ are. Stacking would part them, so it stays the row it is everywhere else. */
+.geo-map-container .geo-detail-pane .promoted-attribute-label-boolean {
+ flex-direction: row;
+ align-items: center;
+ gap: 8px;
+}
+
+/* The widget stands whether the note promotes anything or not, and an empty one would still take
+ its share of the gap between the actions above it and the note below. */
+.geo-map-container .geo-detail-pane .promoted-attributes-widget:not(:has(.promoted-attribute-cell)) {
+ display: none;
}
/*
diff --git a/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsx b/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsx
index 2faaae3d12..c2d8815426 100644
--- a/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsx
+++ b/apps/client/src/widgets/collections/geomap/DetailPane.spec.tsx
@@ -1,3 +1,4 @@
+import $ from "jquery";
import { render } from "preact";
import { act } from "preact/test-utils";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
@@ -8,6 +9,7 @@ import type FNote from "../../../entities/fnote";
import attributes from "../../../services/attributes";
import froca from "../../../services/froca";
import link from "../../../services/link";
+import server from "../../../services/server";
import { buildNote } from "../../../test/easy-froca";
import { useNoteContext, useTriliumEvent } from "../../react/hooks";
import { ParentComponent } from "../../react/react_utils";
@@ -43,6 +45,12 @@ vi.mock("../../NoteDetail", () => ({
}
}));
+// A promoted text field suggests what other notes hold under its name, asked for through the Algolia
+// jQuery plugin and answered by the server. Neither is loaded here.
+type PluggedIn = { autocomplete(...args: unknown[]): PluggedIn };
+($.fn as unknown as PluggedIn).autocomplete = function (this: PluggedIn) { return this; };
+server.get = (async () => []) as unknown as typeof server.get;
+
/** What a marker click hands the handler, and what the pane reads the note out of. */
type Listener = (e?: unknown) => void;
@@ -392,6 +400,40 @@ describe("DetailPane", () => {
});
});
+ /**
+ * A marker is very often a note whose fields say more about the place than its content does — the
+ * grid of them is the quick editor's, standing where the quick editor puts it.
+ */
+ it("offers the note's own promoted fields, and none where a note promotes none", async () => {
+ buildNote({ id: "root", title: "root", children: [
+ {
+ id: "somewhere",
+ title: "Somewhere",
+ "#geolocation": "1,2",
+ "#label:visited": "promoted,single,text",
+ "#visited": "2026-08-04"
+ },
+ { id: "elsewhere", title: "Elsewhere", "#geolocation": "3,4" }
+ ] });
+ const map = fakeMap();
+ await mount([ froca.notes["somewhere"], froca.notes["elsewhere"] ], map);
+
+ map.setUnderPointer([ markerFeature(froca.notes["somewhere"]) ]);
+ await act(async () => map.click());
+ await settle();
+
+ const cell = pane()?.querySelector(".promoted-attribute-cell");
+ expect(cell?.querySelector("label")?.textContent).toBe("visited");
+ expect(cell?.querySelector<HTMLInputElement>("input")?.value).toBe("2026-08-04");
+
+ // Moving between markers is a note switch within the standing pane, so the fields follow it.
+ map.setUnderPointer([ markerFeature(froca.notes["elsewhere"], [ 4, 3 ]) ]);
+ await act(async () => map.click());
+ await settle();
+
+ expect(pane()?.querySelector(".promoted-attribute-cell")).toBeNull();
+ });
+
describe("taking the marker off the map", () => {
function removeButton() {
return container?.querySelector<HTMLButtonElement>(".geo-detail-pane-actions button.bx-trash") ?? null;
diff --git a/apps/client/src/widgets/collections/geomap/DetailPane.tsx b/apps/client/src/widgets/collections/geomap/DetailPane.tsx
index e420f9892d..6cb0ec845f 100644
--- a/apps/client/src/widgets/collections/geomap/DetailPane.tsx
+++ b/apps/client/src/widgets/collections/geomap/DetailPane.tsx
@@ -13,6 +13,7 @@ import TitleRow from "../../layout/TitleRow";
import NoteDetail from "../../NoteDetail";
import ActionButton from "../../react/ActionButton";
import { useNoteLabel } from "../../react/hooks";
+import PromotedAttributes from "../../PromotedAttributes";
import OverlayPanel, { OverlayPanelBody } from "../../react/OverlayPanel";
import { NoteContextContext, ParentComponent } from "../../react/react_utils";
import { moveMarker } from "./api";
@@ -156,6 +157,11 @@ function MarkerDetails({ note, isReadOnly, onClose }: { note: FNote; isReadOnly:
<OverlayPanelBody className="geo-detail-pane-body">
<MarkerActions note={note} isReadOnly={isReadOnly} />
+ {/* Whatever fields the note's own definitions ask for, ahead of the note as the quick
+ editor puts them — a marker is often a note whose type says less about it than
+ its fields do. Nothing at all is shown for a note that promotes none. */}
+ <PromotedAttributes />
+
{/* The note itself, drawn by whichever widget its type calls for — the same one the
quick editor mounts, so a marker is written in exactly as it is anywhere else.
No toolbar stands beside it: the pane asks for the floating one, which the editor