From 3128f2dace0fb3bbd416de8782b8a11ae38e9a14 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 13 Sep 2025 15:12:26 +0300 Subject: [PATCH] fix(react/collections/geomap): corrupted map after closing split --- apps/client/src/widgets/collections/geomap/map.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/client/src/widgets/collections/geomap/map.tsx b/apps/client/src/widgets/collections/geomap/map.tsx index 85c7b9b34..06ce63dc2 100644 --- a/apps/client/src/widgets/collections/geomap/map.tsx +++ b/apps/client/src/widgets/collections/geomap/map.tsx @@ -3,7 +3,7 @@ import L, { control, LatLng, Layer, LeafletMouseEvent } from "leaflet"; import "leaflet/dist/leaflet.css"; import { MAP_LAYERS } from "./map_layer"; import { ComponentChildren, createContext, RefObject } from "preact"; -import { useSyncedRef } from "../../react/hooks"; +import { useElementSize, useSyncedRef } from "../../react/hooks"; export const ParentMap = createContext(null); @@ -125,6 +125,12 @@ export default function Map({ coordinates, zoom, layerName, viewportChanged, chi return () => scaleControl.remove(); }, [ mapRef, scale ]); + // Adapt to container size changes. + const size = useElementSize(containerRef); + useEffect(() => { + mapRef.current?.invalidateSize(); + }, [ size?.width, size?.height ]); + return (