Skip to content

fix(widgets) events in react reverse controlled env#8893

Merged
Pessimistress merged 6 commits intomasterfrom
chr/rearrange-widget-dom
Feb 24, 2026
Merged

fix(widgets) events in react reverse controlled env#8893
Pessimistress merged 6 commits intomasterfrom
chr/rearrange-widget-dom

Conversation

@chrisgervang
Copy link
Copy Markdown
Collaborator

@chrisgervang chrisgervang commented May 14, 2024

Closes #8877

Background

Exploring a way to exclude widgets from the deck event manager and push it above maplibre. Currently mouse event on a widget performs deck picking, which is an unwanted interaction.

propagation_short.mov

Rearranging the DOM so that the deck picker and widgets are peer elements fix the deck picking issue. Also, by nesting the deck children, such as react-map-gl in reversed controlled configuration, the deck widgets events aren't blocked by maplibre.

<!-- react-map-gl reverse controlled DOM -->
<div id="react-deckgl-wrapper">
  <div class="event-manager-root">
    <canvas class="deck-overlay" />
    <div class="react-deck-view">
      <div class="react-map-gl-root" />
      <div class="some-other-child-component" />
    </div>
  </div>
  <div class="deck-widgets-container">
    <div class="deck-view-widgets">
      <div class="fill"/>
      <div class="top-left"/>
    </div>
  </div>
</div>
react-widget-dom.mov

Flavors to test:

  • no basemap
  • React reverse controlled
  • MapboxOverlay overlaid
  • MapboxOverlay interleaved
  • Script tag
  • Python/Jupyter notebook
  • GoogleMapsOverlay

Change List

  • Core
    • If present as a child of parent, selects an .event-manager-root element for EventManager to use for picking.
    • If present as a child of parent, selects an .deck-widgets-container element for WidgetManager to add widgets to.
  • React
    • Nests deck overlay and <DeckGL/> children under .event-manager-root
    • Nests deck widgets under .deck-widgets-container

Note

Medium Risk
Changes the DOM structure and event-root selection for React rendering, which can affect pointer/gesture handling and widget placement across integrations, though it preserves fallbacks for non-React/legacy setups.

Overview
Fixes widget interaction issues in React reverse-controlled basemap setups by splitting the DOM roots for input events vs. widgets.

React DeckGL now renders a .deck-events-root wrapper containing the canvas + children, and a sibling .deck-widgets-root container for widgets. Core Deck initialization is updated to attach EventManager to .deck-events-root (when present) and WidgetManager to .deck-widgets-root (falling back to the prior parents when absent).

The arc website example is updated to include @deck.gl/widgets (Zoom/Compass/Fullscreen) and its stylesheet to exercise the new behavior.

Written by Cursor Bugbot for commit 103fd90. This will update automatically on new commits. Configure here.

@chrisgervang chrisgervang changed the base branch from master to 9.0-release May 14, 2024 00:19
Comment thread modules/core/src/lib/deck.ts Outdated
@chrisgervang chrisgervang changed the title Chr/rearrange widget dom Rearrange DOM to fix widget events in all environments May 19, 2024
Comment thread modules/core/src/lib/deck.ts Outdated
@chrisgervang chrisgervang changed the base branch from 9.0-release to master January 7, 2025 20:02
@chrisgervang chrisgervang marked this pull request as ready for review January 7, 2025 20:03
@chrisgervang chrisgervang changed the title Rearrange DOM to fix widget events in all environments fix(widgets) events in react reverse controlled env Feb 2, 2026
Signed-off-by: Chris Gervang <chris@gervang.com>
Signed-off-by: Chris Gervang <chris@gervang.com>
Signed-off-by: Chris Gervang <chris@gervang.com>
@Pessimistress Pessimistress force-pushed the chr/rearrange-widget-dom branch from 8961626 to b734efa Compare February 23, 2026 17:49
@coveralls
Copy link
Copy Markdown

coveralls commented Feb 23, 2026

Coverage Status

coverage: 91.082% (+0.003%) from 91.079%
when pulling 8ebe54f on chr/rearrange-widget-dom
into 51dc2a3 on master.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

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.

Comment thread modules/react/src/deckgl.ts
@Pessimistress Pessimistress merged commit 2eaa94d into master Feb 24, 2026
5 checks passed
@Pessimistress Pessimistress deleted the chr/rearrange-widget-dom branch February 24, 2026 00:11
import type {Color, PickingInfo, MapViewState} from '@deck.gl/core';
import type {Feature, Polygon, MultiPolygon} from 'geojson';
import {CompassWidget, ZoomWidget, FullscreenWidget} from '@deck.gl/widgets';
import '@deck.gl/widgets/stylesheet.css';
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.

@chrisgervang adding this broke the website build with the latest loaders, any idea why? f939449

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

What's the error? How confident are we it has to do with loaders, or could it also be broken on master?

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.

Module not found: Error: Can't resolve '@deck.gl/widgets/stylesheet.css' in '/home/runner/work/deck.gl/deck.gl/examples/website/arc'

see: https://github.com/visgl/deck.gl/actions/runs/22398533353/job/64838419323

It doesn't seem broken on master, so it's a bit of a mystery to me

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] Widgets render below react-map-gl basemap

4 participants