mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
fix(react/collections/geomap): corrupted map after closing split
This commit is contained in:
@@ -3,7 +3,7 @@ import L, { control, LatLng, Layer, LeafletMouseEvent } from "leaflet";
|
|||||||
import "leaflet/dist/leaflet.css";
|
import "leaflet/dist/leaflet.css";
|
||||||
import { MAP_LAYERS } from "./map_layer";
|
import { MAP_LAYERS } from "./map_layer";
|
||||||
import { ComponentChildren, createContext, RefObject } from "preact";
|
import { ComponentChildren, createContext, RefObject } from "preact";
|
||||||
import { useSyncedRef } from "../../react/hooks";
|
import { useElementSize, useSyncedRef } from "../../react/hooks";
|
||||||
|
|
||||||
export const ParentMap = createContext<L.Map | null>(null);
|
export const ParentMap = createContext<L.Map | null>(null);
|
||||||
|
|
||||||
@@ -125,6 +125,12 @@ export default function Map({ coordinates, zoom, layerName, viewportChanged, chi
|
|||||||
return () => scaleControl.remove();
|
return () => scaleControl.remove();
|
||||||
}, [ mapRef, scale ]);
|
}, [ mapRef, scale ]);
|
||||||
|
|
||||||
|
// Adapt to container size changes.
|
||||||
|
const size = useElementSize(containerRef);
|
||||||
|
useEffect(() => {
|
||||||
|
mapRef.current?.invalidateSize();
|
||||||
|
}, [ size?.width, size?.height ]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
|
|||||||
Reference in New Issue
Block a user