Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rearrange DOM to fix widget events in all environments #8893

Draft
wants to merge 3 commits into
base: 9.0-release
Choose a base branch
from

Conversation

chrisgervang
Copy link
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

@chrisgervang chrisgervang changed the base branch from master to 9.0-release May 14, 2024 00:19
@chrisgervang chrisgervang changed the title Chr/rearrange widget dom Rearrange DOM to fix widget events in all environments May 19, 2024
@@ -1007,9 +1009,13 @@ export default class Deck<ViewsT extends ViewOrViews = null> {

this.deckPicker = new DeckPicker(this.device);

const parent = this.props.parent || document.body;
const widgetParent =
parent.querySelector<HTMLDivElement>('.deck-widgets-container') || this.canvas?.parentElement;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be this.props.parent?.querySelector() like the eventRoot? Searching under document.body is suspicious...

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.

2 participants