Skip to content

fix: reset maxBounds to null when prop is removed - #2617

Open
cpruijsen wants to merge 2 commits into
visgl:masterfrom
cpruijsen:fix/issue-2591
Open

cpruijsen wants to merge 2 commits into
visgl:masterfrom
cpruijsen:fix/issue-2591

Conversation

@cpruijsen

Copy link
Copy Markdown

DEFAULT_SETTINGS.maxBounds was [-180, -85.051129, 180, 85.051129], a full 360 degree longitude
span. When a controlled maxBounds prop is removed, _updateSettings falls back to that default and
calls setMaxBounds with it, and a bound that wide makes maplibre-gl-js compute a singular matrix
and crash (maplibre-gl-js#6148). Passing no maxBounds at all is fine; it is the fallback that
installs the bad value, so the crash only appears after a prop goes away.

This changes the default to null in both modules/react-maplibre/src/maplibre/maplibre.ts and
modules/react-mapbox/src/mapbox/mapbox.ts, so the fallback clears the constraint rather than
installing a whole-world one. Both modules carry the identical fallback, which is why both are
changed together.

Filed here rather than on visgl/react-maplibre, which is archived and points back to this repo.

Fixes #2591

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 visgl#2591
Omitting the prop is the _updateSettings fallback that previously
called setMaxBounds with a 360° world span.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DEFAULT_SETTINGS.maxBounds in @vis.gl/react-maplibre has 360° longitude span, triggers maplibre-gl-js#6148 crash via _updateSettings fallback

1 participant