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(geomap): keep the markers on an image map from fading when one is selected
Elian Dorand9883a81e924
diff --git a/apps/client/src/widgets/collections/geomap/Markers.spec.tsx b/apps/client/src/widgets/collections/geomap/Markers.spec.tsxindex cebf15fef8..9d11bbd9f1 100644--- a/apps/client/src/widgets/collections/geomap/Markers.spec.tsx+++ b/apps/client/src/widgets/collections/geomap/Markers.spec.tsx@@ -620,6 +620,10 @@ describe("Markers", () => {// The glow stands from the start, aimed at nothing: no note's id is the empty string.expect(map.layer(SELECTION_LAYER)?.filter).toEqual([ "==", [ "get", "id" ], "" ]);expect(map.layer(MARKER_LAYER)?.layout?.["icon-size"]).toBe(1);+ // An expression even with nothing to sort, so selecting a marker never turns it from a+ // constant into one (see selectionSortKey).+ expect(map.layer(MARKER_LAYER)?.layout?.["symbol-sort-key"])+ .toEqual([ "case", [ "==", [ "get", "id" ], "" ], 1, 0 ]);const layersBefore = map.calls.addLayer;// A marker is selected: everything is repointed rather than rebuilt.@@ -640,6 +644,8 @@ describe("Markers", () => {await mount([ note ], map, parent, { isDarkTheme: true });expect(map.property(SELECTION_LAYER, "filter")).toEqual([ "==", [ "get", "id" ], "" ]);expect(map.property(MARKER_LAYER, "icon-size")).toBe(1);+ expect(map.property(MARKER_LAYER, "symbol-sort-key"))+ .toEqual([ "case", [ "==", [ "get", "id" ], "" ], 1, 0 ]);});/**diff --git a/apps/client/src/widgets/collections/geomap/Markers.tsx b/apps/client/src/widgets/collections/geomap/Markers.tsxindex 49363de038..1b070b9da7 100644--- a/apps/client/src/widgets/collections/geomap/Markers.tsx+++ b/apps/client/src/widgets/collections/geomap/Markers.tsx@@ -391,9 +391,15 @@ function selectionPinSize(selectedNoteId: string | null): ExpressionSpecificatioreturn selectedNoteId ? [ "case", isSelected(selectedNoteId), SELECTED_PIN_SCALE, 1 ] : 1;}-/** The selected pin sorted above its neighbours, higher keys being drawn later and so on top. */-function selectionSortKey(selectedNoteId: string | null): ExpressionSpecification | number {- return selectedNoteId ? [ "case", isSelected(selectedNoteId), 1, 0 ] : 0;+/**+ * The selected pin sorted above its neighbours, higher keys being drawn later and so on top.+ *+ * An expression even when nothing is selected. A constant key built into the tiles makes MapLibre+ * place none of their symbols once the key becomes an expression, so every marker fades out and+ * back in until the tiles are rebuilt.+ */+function selectionSortKey(selectedNoteId: string | null): ExpressionSpecification {+ return [ "case", isSelected(selectedNoteId), 1, 0 ];}/**