Skip to content

Commit 05fdfad

Browse files
committed
Debug prod
1 parent 251a76e commit 05fdfad

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/components/CoordinatesDisplay.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import { searchOverlayHelper } from '../utils/externalSearchUtils';
88

99
export function CoordinatesDisplay({
1010
flipped,
11-
mapRef,
11+
mapObj,
1212
externalSearchRef,
1313
externalSearchMarkerRef,
1414
}: {
1515
flipped: boolean;
16-
mapRef: React.RefObject<Map | null>;
16+
mapObj: Map;
1717
externalSearchRef: React.RefObject<HTMLDivElement | null>;
1818
externalSearchMarkerRef: React.RefObject<Feature<Geometry> | null>;
1919
}) {
@@ -56,17 +56,15 @@ export function CoordinatesDisplay({
5656
}, []);
5757

5858
useEffect(() => {
59-
if (!mapRef.current) return;
60-
const currentMapRef = mapRef.current;
59+
const currentMapRef = mapObj;
6160
const updateCoords = (e: MapBrowserEvent) => setCoordinates(e.coordinate);
6261
currentMapRef.on('pointermove', updateCoords);
6362
return () => currentMapRef.un('pointermove', updateCoords);
64-
}, [mapRef]);
63+
}, []);
6564

6665
const onSubmit = useCallback(
6766
(e: FormEvent) => {
6867
e.preventDefault();
69-
if (!mapRef.current) return;
7068
const formData = new FormData(e.target as HTMLFormElement);
7169
const raStr = String(formData.get('ra'));
7270
const decStr = String(formData.get('dec'));
@@ -79,9 +77,9 @@ export function CoordinatesDisplay({
7977
[ra, dec],
8078
flipped
8179
);
82-
mapRef.current.getView().setCenter(transformedCoords);
80+
mapObj.getView().setCenter(transformedCoords);
8381
searchOverlayHelper(
84-
mapRef.current,
82+
mapObj,
8583
externalSearchRef,
8684
externalSearchMarkerRef,
8785
transformedCoords,
@@ -93,7 +91,7 @@ export function CoordinatesDisplay({
9391
setShowCoordInputs(false);
9492
(e.target as HTMLFormElement).reset();
9593
},
96-
[mapRef, externalSearchRef, externalSearchMarkerRef, flipped]
94+
[mapObj, externalSearchRef, externalSearchMarkerRef, flipped]
9795
);
9896

9997
// Return early if coordinates aren't defined

src/components/OpenLayersMap.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,14 @@ export function OpenLayersMap({
571571
goForward={goForward}
572572
/>
573573
<GraticuleLayer mapRef={mapRef} flipped={flipTiles} />
574-
<CoordinatesDisplay
575-
flipped={flipTiles}
576-
mapRef={mapRef}
577-
externalSearchRef={externalSearchRef}
578-
externalSearchMarkerRef={externalSearchMarkerRef}
579-
/>
574+
{mapRef.current && (
575+
<CoordinatesDisplay
576+
flipped={flipTiles}
577+
mapObj={mapRef.current}
578+
externalSearchRef={externalSearchRef}
579+
externalSearchMarkerRef={externalSearchMarkerRef}
580+
/>
581+
)}
580582
</div>
581583
);
582584
}

src/components/layers/GraticuleLayer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function GraticuleLayer({
7777
mapRef.current.addLayer(graticule1);
7878
mapRef.current.addLayer(graticule2);
7979
}
80-
}, [mapRef, flipped, handleLatLabelFormat, handleLonLabelFormat]);
80+
}, [mapRef.current, flipped]);
8181

8282
return null;
8383
}

0 commit comments

Comments
 (0)