diff --git a/src/landscape/components/LandscapeSharedDataVisualization.test.js b/src/landscape/components/LandscapeSharedDataVisualization.test.js index ad55c6798..41e3443e4 100644 --- a/src/landscape/components/LandscapeSharedDataVisualization.test.js +++ b/src/landscape/components/LandscapeSharedDataVisualization.test.js @@ -233,9 +233,9 @@ test('LandscapeSharedDataVisualization: Display visualization', async () => { ).toBeInTheDocument(); // Map - await waitFor(() => expect(map.addSource).toHaveBeenCalledTimes(3)); - expect(map.addSource.mock.calls[2][0]).toEqual('visualization'); - const geojson = map.addSource.mock.calls[2][1].data; + await waitFor(() => expect(map.addSource).toHaveBeenCalledTimes(1)); + expect(map.addSource.mock.calls[0][0]).toEqual('visualization'); + const geojson = map.addSource.mock.calls[0][1].data; expect(geojson.features.length).toBe(3); expect(map.addLayer).toHaveBeenCalledTimes(3); diff --git a/src/sharedData/visualization/components/Visualization.js b/src/sharedData/visualization/components/Visualization.js index aa783e203..c3bc6f080 100644 --- a/src/sharedData/visualization/components/Visualization.js +++ b/src/sharedData/visualization/components/Visualization.js @@ -333,13 +333,15 @@ const MapboxLayer = props => { ); })(); - const bounds = useConfigBounds ? visualizationConfigBounds : geoJsonBounds; + const bounds = + useConfigBounds && visualizationConfigBounds + ? visualizationConfigBounds + : geoJsonBounds; if (bounds && !bounds.isEmpty()) { map.fitBounds(bounds, { padding: 50, animate: false, - maxZoom: 10, }); } }, [map, visualizationConfig?.viewportConfig?.bounds, useConfigBounds]); @@ -376,6 +378,7 @@ const Visualization = props => { <> { [setViewportConfig] ); - const onPublish = () => { + const onPublish = useCallback(() => { const completeConfig = { ...visualizationConfig, viewportConfig, @@ -104,7 +104,16 @@ const PreviewStep = props => { onSaved(data.payload.slug); } }); - }; + }, [ + dispatch, + group, + onSaved, + owner.name, + selectedFile, + trackEvent, + viewportConfig, + visualizationConfig, + ]); return ( <>