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
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/website/arc/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {scaleQuantile} from 'd3-scale';

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';

// Source data GeoJSON
const DATA_URL =
Expand Down Expand Up @@ -138,6 +140,7 @@ export default function App({
initialViewState={INITIAL_VIEW_STATE}
controller={true}
getTooltip={getTooltip}
widgets={[new ZoomWidget({}), new CompassWidget({}), new FullscreenWidget({})]}
>
<Map reuseMaps mapStyle={mapStyle} />
</DeckGL>
Expand Down
7 changes: 6 additions & 1 deletion modules/core/src/lib/deck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1007,9 +1007,14 @@ export default class Deck<ViewsT extends ViewOrViews = null> {

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

const widgetContainer = document.createElement('div');
widgetContainer.id = 'deck-widgets-container';
const parent = this.props.parent?.parentElement || document.body;
chrisgervang marked this conversation as resolved.
Show resolved Hide resolved
parent.appendChild(widgetContainer);

this.widgetManager = new WidgetManager({
deck: this,
parentElement: this.canvas?.parentElement
parentElement: widgetContainer
});
this.widgetManager.addDefault(new Tooltip());

Expand Down
10 changes: 8 additions & 2 deletions modules/react/src/deckgl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,17 @@ function DeckGLWithRef<ViewsT extends ViewOrViews = null>(
style: canvasStyle
});

const eventRoot = createElement(
'div',
{key: 'event-manager-root', id: 'event-manager-root', ref: containerRef},
[canvas, childrenUnderViews]
);

// Render deck.gl as the last child
thisRef.control = createElement(
'div',
{id: `${id || 'deckgl'}-wrapper`, ref: containerRef, style: containerStyle},
[canvas, childrenUnderViews]
{id: `${id || 'deckgl'}-wrapper`, style: containerStyle},
[eventRoot]
);
}

Expand Down