feat(mapbox): Add widget support to MapboxOverlay via IControl adapter#9963
Open
chrisgervang wants to merge 7 commits intomasterfrom
Open
feat(mapbox): Add widget support to MapboxOverlay via IControl adapter#9963chrisgervang wants to merge 7 commits intomasterfrom
chrisgervang wants to merge 7 commits intomasterfrom
Conversation
40d85b9 to
9426c8c
Compare
| for (const widget of mapboxWidgets) { | ||
| const existingControl = existingControlsById.get(widget.id); | ||
|
|
||
| if (existingControl && existingControl.widget.placement === widget.placement) { |
There was a problem hiding this comment.
Placement change undetected for mutated widget objects
Low Severity
The placement comparison existingControl.widget.placement === widget.placement fails to detect placement changes when the same widget object is passed with a mutated placement property. After setWidget(widget) is called in a previous iteration, existingControl.widget becomes the same reference as the current widget. When both sides of the comparison reference the same object, the comparison is trivially true regardless of whether placement was actually changed. The control remains in its original map position even though the widget's placement changed.
Enable deck widgets to coexist with native Mapbox/MapLibre controls without DOM overlap by rendering widgets with viewId: 'mapbox' into the map's control container system. - Add DeckWidgetControl class that wraps deck widgets as IControls - Process widgets with viewId: 'mapbox' in MapboxOverlay - Set widget._container to Mapbox-positioned element via IControl - Widgets stack correctly with native controls in same container Closes #9962 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add TestWidget class for testing widget integration - Test regular widgets render in deck container - Test widgets with viewId: 'mapbox' are wrapped as IControl - Test mixed widgets (regular + mapbox) - Test setProps updates widget controls - Test interleaved mode widget support - Update mock map to support control positions and hasControl Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Overlaid mode tests create their own Deck instances which can cause GL context corruption when sharing contexts across tests. Using an isolated WebGLDevice for these tests prevents hangs in the test suite. Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
…d rootElement When setProps was called with widgets, _processWidgets would destroy and recreate all DeckWidgetControls. This removed the container from the DOM, orphaning the widget's rootElement since WidgetManager wouldn't re-attach it (same widget id means no change detected). Now matches widgets by id (like WidgetManager) and only recreates controls when the widget is new or placement changes. For existing widgets with same id and placement, the container is preserved and copied to the new widget instance to support React patterns where widgets are recreated on render. Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
When _processWidgets reuses a DeckWidgetControl for a new widget instance with the same id and placement, the control's internal _widget reference must be updated. Otherwise the control references the old widget, causing incorrect behavior in onRemove() and potential memory leaks. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
79355a6 to
287b467
Compare
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.


Closes #9962
Background
Enable deck widgets to coexist with native Mapbox/MapLibre controls without DOM overlap by rendering widgets with
viewId: 'mapbox'into the map's control container system via the new_containerprop.Change List
DeckWidgetControlclass that wraps deck widgets as Mapbox IControlsviewId: 'mapbox'in MapboxOverlay, automatically wrapping them as IControlswidget.props._containerto Mapbox-positioned element so WidgetManager appends thereNote
Medium Risk
Adds new widget lifecycle/DOM integration to
MapboxOverlaythat mutateswidget.props._containerand manages Mapbox controls; regressions could show up as leaked controls, incorrect positioning, or widget rendering issues acrosssetProps/interleaved modes.Overview
Adds first-class widget support in
MapboxOverlayby adapting deck.gl widgets into Mapbox/MapLibre controls. Widgets withviewId: 'mapbox'are now wrapped in a newDeckWidgetControland added viamap.addControl, so they render inside the map’s native control containers (and avoid overlapping the overlay container).MapboxOverlaynow processeswidgetsbefore Deck initialization and beforedeck.setProps, reusing/removing controls by widgetid(and only recreating whenplacementchanges) and cleaning them up ononRemove. Tests and mocks were updated to cover widget/control behavior and to stabilize GL usage in overlaid tests.Written by Cursor Bugbot for commit 287b467. This will update automatically on new commits. Configure here.