Skip to content

fix: preserve map dragging with controlled camera props - #1108

Merged
usefulthink merged 1 commit into
visgl:mainfrom
mvanhorn:fix/425-controlled-camera-drag
Oct 30, 2026
Merged

usefulthink merged 1 commit into
visgl:mainfrom
mvanhorn:fix/425-controlled-camera-drag

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Background

Maps using controlled camera props can stop responding to mouse dragging and other interactions after camera changes are fed back into state.

After applying controlled camera props, the tracked camera state was not updated until the map emitted its change event. A render occurring before that event could therefore reapply the same camera values repeatedly, interfering with interaction.

Summary of the fix

The camera hook now updates its tracked state immediately after calling moveCamera, including renders that occur before the map event arrives. A regression test verifies that unchanged controlled camera props do not trigger repeated moveCamera calls.

Verification

The map component test suite passes, including the regression test for repeated controlled camera updates.

Fixes #425

The camera hook now updates its tracked state immediately after calling
moveCamera, including renders that occur before the map event arrives. A
regression test verifies that unchanged controlled camera props do not
trigger repeated moveCamera calls.

Fixes visgl#425
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

The camera hook now records requested camera changes immediately after moveCamera. This prevents unchanged controlled props from sending the same change again before the map reports its new view.

  • Controlled camera updates no longer repeat before the map reports them.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[React renders camera props] --> B{Requested values differ?}
  B -->|No| C[Leave camera unchanged]
  B -->|Yes| D[Call moveCamera]
  D --> E[Immediately record requested values]
  E --> F[Same props do not repeat the move]
  G[bounds_changed event] --> H[Record actual map values]
  H --> A
Loading

Reviews (1) · Last reviewed commit: "fix: preserve map dragging with controll..." · Reviewed by Greptile

@usefulthink usefulthink left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, great find!

@usefulthink
usefulthink merged commit 7758d7c into visgl:main Oct 30, 2026
4 checks passed
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.

[Bug] mouse-movement not working when using some controlled props

2 participants