From 1dcb6a5e7f39fc1e8d89a1b87558e65501491536 Mon Sep 17 00:00:00 2001 From: Christopher Pruijsen Date: Sun, 13 Sep 2026 09:22:03 +0000 Subject: [PATCH 1/2] fix: reset maxBounds to null when prop is removed DEFAULT_SETTINGS.maxBounds was [-180, -85.051129, 180, 85.051129], a 360-degree longitude span that triggers the singular projection matrix crash in maplibre-gl-js#6148 when _updateSettings restores it after the prop is removed. null clears the constraint, matching the library default of no bounds. Fixes #2591 --- modules/react-mapbox/src/mapbox/mapbox.ts | 2 +- modules/react-maplibre/src/maplibre/maplibre.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/react-mapbox/src/mapbox/mapbox.ts b/modules/react-mapbox/src/mapbox/mapbox.ts index bb40fd7c3..ce92168aa 100644 --- a/modules/react-mapbox/src/mapbox/mapbox.ts +++ b/modules/react-mapbox/src/mapbox/mapbox.ts @@ -90,7 +90,7 @@ const DEFAULT_SETTINGS = { maxZoom: 22, minPitch: 0, maxPitch: 85, - maxBounds: [-180, -85.051129, 180, 85.051129], + maxBounds: null, projection: 'mercator', renderWorldCopies: true }; diff --git a/modules/react-maplibre/src/maplibre/maplibre.ts b/modules/react-maplibre/src/maplibre/maplibre.ts index cd3e35205..4043c20e6 100644 --- a/modules/react-maplibre/src/maplibre/maplibre.ts +++ b/modules/react-maplibre/src/maplibre/maplibre.ts @@ -104,7 +104,7 @@ export type MaplibreProps = Partial & const DEFAULT_STYLE = {version: 8, sources: {}, layers: []} as StyleSpecification; const DEFAULT_SETTINGS = { - maxBounds: [-180, -85.051129, 180, 85.051129], + maxBounds: null, projection: 'mercator', renderWorldCopies: true }; From d1096aa6b0be030fa063b3761e1b25a887ac4cf0 Mon Sep 17 00:00:00 2001 From: Christopher Pruijsen Date: Sun, 13 Sep 2026 13:50:40 +0000 Subject: [PATCH 2/2] test: cover maxBounds reset when the prop is omitted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Omitting the prop is the _updateSettings fallback that previously called setMaxBounds with a 360° world span. --- .../test/components/map.spec.jsx | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/react-maplibre/test/components/map.spec.jsx b/modules/react-maplibre/test/components/map.spec.jsx index f9982c904..999d63f57 100644 --- a/modules/react-maplibre/test/components/map.spec.jsx +++ b/modules/react-maplibre/test/components/map.spec.jsx @@ -156,6 +156,27 @@ test('Map resets camera constraints when reusing a map', async () => { } }); +test('Map resets maxBounds when the prop is removed', async () => { + const root = createRoot(document.createElement('div')); + const mapRef = {current: null}; + const maxBounds = [-120, 20, -80, 50]; + + await act(() => root.render()); + await waitForMapLoad(mapRef); + + const applied = mapRef.current.getMaxBounds(); + expect(applied.getWest()).toBe(-120); + expect(applied.getSouth()).toBe(20); + expect(applied.getEast()).toBe(-80); + expect(applied.getNorth()).toBe(50); + + await act(() => root.render()); + + expect(mapRef.current.getMaxBounds()).toBe(null); + + await act(() => root.unmount()); +}); + test('Map#uncontrolled', async () => { await actUntil(resolveTest => { const root = createRoot(document.createElement('div'));