fix(camera): reset maxBounds when the prop is removed - #4293
Open
benjilollebg wants to merge 1 commit into
Open
Conversation
Passing null bounds to CameraBoundsOptions leaves the previous value unchanged in the Mapbox SDK, so removing the Camera maxBounds prop kept the old restriction (and setting world bounds manually blocks panning across the antimeridian). Reset to the SDK default (infinite world bounds) instead, on both Android and iOS, matching the existing null-reset handling of minZoom/maxZoom. The RestrictMapBounds example now has a button toggling maxBounds on/off to demonstrate/reproduce this. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
benjilollebg
requested a deployment
to
CI with Mapbox Tokens
September 4, 2026 08:21 — with
GitHub Actions
Waiting
benjilollebg
requested a deployment
to
CI with Mapbox Tokens
September 4, 2026 08:21 — with
GitHub Actions
Waiting
benjilollebg
requested a deployment
to
CI with Mapbox Tokens
September 4, 2026 08:21 — with
GitHub Actions
Waiting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Removing the
Camera.maxBoundsprop (setting it back tonull/undefined) does not remove the bounds restriction from the map.Both platforms pass a nil bounds into
CameraBoundsOptionswhen the prop is cleared:RNMBXCamera.updateMaxBounds):builder.bounds(mMaxBounds?.toBounds())RNMBXCamera._updateMaxBounds):options.bounds = nilIn the Mapbox SDKs, a nil field in
CameraBoundsOptionsmeans "leave this property unchanged", so the previous restriction silently stays active. The common userland workaround — passing{ne: [180, 90], sw: [-180, -90]}— is not equivalent to the default either: it creates a finite world bounds that blocks panning across the antimeridian (the map gets stuck at ±180°), because the SDK default is an infinite world bounds.This PR resets the bounds to the SDK default when the prop is removed:
CoordinateBounds.world()(the SDK's documented default,infiniteBounds = true)CoordinateBounds(southwest:northeast:infiniteBounds: true)This matches how
minZoom/maxZoomalready handle null in the same function (// Passing null does not reset this value.).Checklist
CONTRIBUTING.mdyarn generatein the root folder (no generated code affected — native-only change + example)/exampleapp./example)Component to reproduce the issue you're fixing
The
RestrictMapBoundsexample is updated in this PR to act as the reproducer: it now has a bubble button togglingmaxBoundsbetween the Cornwall bounds andnull.{ne:[180,90], sw:[-180,-90]}workaround).Honest verification note: this was diagnosed from the SDK behavior (nil
CameraBoundsOptionsfields are documented as no-ops) and the fix mirrors the existing null-handling ofminZoom/maxZoomtwo lines below. I hit this in a real app (entering/leaving a floor view that sets/clearsmaxBounds), where clearing the prop demonstrably left the restriction active and the world-bounds workaround got stuck at the dateline. I have not yet been able to run the/exampleapp builds for the four checklist configurations — happy to iterate if CI or maintainers spot anything.🤖 Generated with Claude Code