From 5c00131a96c81d686b0e0142e0c4829dbdeff7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Prod=27homme?= Date: Mon, 2 Dec 2024 15:04:28 +0100 Subject: [PATCH] fix(SKY30-507): Remove crash when collapsing sidebar --- frontend/src/components/map/index.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/map/index.tsx b/frontend/src/components/map/index.tsx index 2eb48172..c935dcec 100644 --- a/frontend/src/components/map/index.tsx +++ b/frontend/src/components/map/index.tsx @@ -54,16 +54,19 @@ export const Map: FC = ({ const handleFitBounds = useCallback(() => { if (mapRef && bounds) { const { bbox, options } = bounds; - // enabling fly mode avoids the map to be interrupted during the bounds transition - setFlying(true); - - mapRef.fitBounds( - [ - [bbox[0], bbox[1]], - [bbox[2], bbox[3]], - ], - options - ); + + if (bbox) { + // enabling fly mode avoids the map to be interrupted during the bounds transition + setFlying(true); + + mapRef.fitBounds( + [ + [bbox[0], bbox[1]], + [bbox[2], bbox[3]], + ], + options + ); + } } }, [bounds, mapRef]);