Skip to content

feat(mapbox): Add widget support to MapboxOverlay via IControl adapter - #9963

Open
chrisgervang wants to merge 11 commits into
masterfrom
chr/mapbox-widget-support
Open

feat(mapbox): Add widget support to MapboxOverlay via IControl adapter#9963
chrisgervang wants to merge 11 commits into
masterfrom
chr/mapbox-widget-support

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Jan 25, 2026

Copy link
Copy Markdown
Collaborator

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 _container prop.

Screenshot 2026-04-06 at 5 27 21 PM

Change List

  • Add DeckWidgetControl class that wraps deck widgets as Mapbox IControls
  • Process widgets with viewId: 'mapbox' in MapboxOverlay, automatically wrapping them as IControls
  • Set widget.props._container to Mapbox-positioned element so WidgetManager appends there
  • Widgets stack correctly with native controls in the same DOM container, preventing overlap

Note

Medium Risk
Changes DOM/control lifecycle integration with Mapbox/MapLibre and widget _container timing; scope is UI positioning with broad test coverage, not core rendering or auth.

Overview
MapboxOverlay can now place deck.gl widgets in the basemap’s native control UI by setting viewId: 'mapbox' on a widget. Those widgets are wrapped as DeckWidgetControl (IControl) instances, widget.props._container is set before Deck/WidgetManager init, and controls are added/updated/removed on setProps (reuse by widget id when placement is unchanged).

placement: 'fill' widgets attach to map.getContainer() instead of the control div (with CSS to hide the empty control and fix margins/hover styles in stylesheet.css). onRemove avoids double-removing child controls when the overlay is already off the map’s control list.

Docs add a Using Widgets section on MapboxOverlay (limitations for view/canvas widgets) and a whats-new note. Tests and the Mapbox mock (hasControl, removeControl) cover overlaid/interleaved lifecycle, fill vs corner placement, and map remove().

Reviewed by Cursor Bugbot for commit 719ccdb. Bugbot is set up for automated code reviews on this repo. Configure here.

@coveralls

coveralls commented Jan 25, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 82.56% (+0.06%) from 82.504% — chr/mapbox-widget-support into master

Comment thread modules/mapbox/src/mapbox-overlay.ts
@chrisgervang chrisgervang mentioned this pull request Jan 25, 2026
62 tasks
Comment thread modules/mapbox/src/deck-widget-control.ts Outdated
@chrisgervang chrisgervang added this to the v9.3 milestone Feb 2, 2026
@chrisgervang
chrisgervang force-pushed the chr/mapbox-widget-support branch from 40d85b9 to 9426c8c Compare February 4, 2026 23:24
Comment thread modules/mapbox/src/mapbox-overlay.ts
Comment thread modules/mapbox/src/mapbox-overlay.ts Outdated
Comment thread modules/mapbox/src/mapbox-overlay.ts
@chrisgervang
chrisgervang force-pushed the chr/mapbox-widget-support branch from 79355a6 to 287b467 Compare February 27, 2026 19:08
@chrisgervang
chrisgervang force-pushed the chr/mapbox-widget-support branch from 287b467 to e793c90 Compare March 9, 2026 18:06
Comment thread modules/mapbox/src/deck-widget-control.ts
@ibgreen ibgreen mentioned this pull request Mar 22, 2026
31 tasks
Comment thread test/modules/mapbox/mapbox-overlay.spec.ts Outdated
Comment thread modules/mapbox/src/mapbox-overlay.ts
Comment thread modules/mapbox/src/mapbox-overlay.ts
Comment thread examples/get-started/pure-js/maplibre/app.js Outdated
@ibgreen ibgreen mentioned this pull request May 2, 2026
59 tasks
@chrisgervang chrisgervang modified the milestones: v9.3, v9.4 Jun 11, 2026
Widgets with `viewId: 'mapbox'` are extracted from the deck overlay and
wrapped as native map IControl instances, positioning them alongside
native controls like NavigationControl.

- Add DeckWidgetControl IControl adapter
- Update MapboxOverlay to process widgets and manage control lifecycle
- Suppress widget margin inside basemap control containers (CSS)
- Add unit tests for widget support in MapboxOverlay
- Add "Using Widgets" guide to MapboxOverlay docs
- Add whats-new entry

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chrisgervang
chrisgervang force-pushed the chr/mapbox-widget-support branch from 76f0325 to c3668c5 Compare June 12, 2026 18:06
…ntainers

Fill widgets (placement: 'fill') use the map container as their parent
instead of the control div, since the basemap's transform: translate(0)
creates a small containing block that breaks position: absolute spanning.
The empty control div is hidden via display: none.

Reset basemap button hover/active background-color that leaks into deck
widget buttons via .mapboxgl-ctrl / .maplibregl-ctrl selectors.

Add 20 edge case tests covering widget lifecycle, DOM structure, fill
widget container routing, setProps preservation, placement changes,
map.remove() cleanup, and duplicate widget ids.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 719ccdb. Configure here.

this._widget.props._container = map.getContainer() as HTMLDivElement;
} else {
this._widget.props._container = this._container;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fill widgets block map interaction

High Severity

Fill widgets with viewId: 'mapbox' set _container to map.getContainer() and are appended there directly. That skips WidgetManager's pointer-events: none overlay wrapper, so full-bleed roots like SplitterWidget keep default pointer-events: auto and capture pan/zoom over the whole map. Only explicit pointer-events: auto children were meant to be interactive.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 719ccdb. Configure here.

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.

feat(mapbox): Add widget support to MapboxOverlay via IControl adapter

3 participants