Skip to content

fix(react): align widget root with the DeckGL canvas - #10724

Merged
chrisgervang merged 11 commits into
visgl:masterfrom
brandon-julio-t:fix/react-widget-root-layout
Sep 30, 2026
Merged

chrisgervang merged 11 commits into
visgl:masterfrom
brandon-julio-t:fix/react-widget-root-layout

Conversation

@brandon-julio-t

@brandon-julio-t brandon-julio-t commented Sep 18, 2026 •

Copy link
Copy Markdown

Closes #10723

Background

The React widget root falls below the canvas, positioning tooltips offscreen. A dedicated deck-root containing block aligns the canvas and widgets even when the outer wrapper uses position: static.

The added DOM level changes direct-child CSS selectors. Absolutely positioned view children now align with the canvas inside wrapper padding/borders; applications compensating for the previous offset may see a shift.

Change List

  • Align DeckGL canvas and widgets within an internal container
  • Preserve pointer targeting through empty overlay space
  • Verify fill-widget containers and elements match all four canvas edges
  • Cover positioning modes, percentage sizing, resizing, and corner widgets
  • Release test-owned WebGL contexts after unmount
  • Unit tests

Verified: 73 focused browser tests, 19 smoke tests, lint. Full coverage CI passed on cce39c7; CI for this review follow-up is pending.

Before/after tooltip hover:

tooltip-before-after.webm

Tooltip restored at the hovered point

Static wrapper: original PR (left), containing-block fix (right):

Canvas and widget bounds within a static wrapper


Note

Medium Risk
The extra DOM nesting and moving the Deck parent ref can shift layout for apps using direct-child CSS or compensating for the old widget offset.

Overview
Fixes React DeckGL widget/tooltip misalignment by changing the rendered DOM so the canvas and widget layer share one layout box.

The outer #deckgl-wrapper now only carries caller style/width/height, while a new inner .deck-root (with containerRef) is position: relative and holds the event/canvas tree plus .deck-widgets-root. The widget root gets inline position: absolute; inset: 0; pointer-events: none so tooltips, corner widgets, and fill placements track the canvas without relying on widget stylesheet CSS, including when the wrapper is position: static or uses padding/margins.

Tests add a matrix covering absolute/static positioning, pixel vs percentage sizing, resize, tooltip coordinates, fill-widget bounds, and map pointer hit-testing; WebGPU “wait for final size” cases now assert sizes via .deck-root and padding instead of mocking wrapper dimensions.

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

@greptile-apps

greptile-apps Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adjusts widget positioning layout in the React wrapper.

The PR appears safe to merge based on the reviewed changes.

Summary

The PR places the canvas and widget overlay inside a positioned .deck-root, keeping widgets aligned with the canvas even when the outer wrapper is static.

  • Adds browser coverage for widget placement, resizing, pointer targeting, and WebGPU sizing.
  • The previously reported containing-block issue is fixed; its thread is resolved.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  W["#deckgl-wrapper: user style"] --> R[".deck-root: positioned canvas-sized container"]
  R --> C["Event and canvas tree"]
  R --> O[".deck-widgets-root: aligned overlay"]
Loading

Reviews (10) · Last reviewed commit: "Merge branch 'master' into fix/react-wid..."

Comment thread modules/react/src/deckgl.ts Resolved

@chrisgervang chrisgervang left a comment

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.

Thanks for including an issue and visual explanations.

Do we have sufficient coverage for fill widgets? They should continue to get a container that matches the deck canvas

@brandon-julio-t

Copy link
Copy Markdown
Author

Thanks for the review and approval, @chrisgervang!

Good point about fill widgets. I added explicit coverage in fdaa57f: both the .fill container and the fill widget itself must match all four canvas edges, before and after resizing. These assertions run in the same parameterized test across absolute, relative, and static wrappers with numeric and percentage dimensions.

All 42 focused browser tests pass (one existing skip), along with the 19 smoke tests, lint, and build. I've also updated the branch with current master. The earlier full coverage CI failed with WebGL uniform-block errors; a fresh full-suite result is still outstanding.

@coveralls

coveralls commented Sep 21, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 82.487% (-0.02%) from 82.505% — brandon-julio-t:fix/react-widget-root-layout into visgl:master

Comment thread modules/react/src/deckgl.ts Outdated
{id: `${id || 'deckgl'}-wrapper`, ref: containerRef, style: containerStyle},
[eventRoot, widgetRoot]
// Preserve a containing block even when the caller puts the wrapper in normal flow.
createElement('div', {style: {position: 'relative', width: '100%', height: '100%'}}, [

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.

Can this div get a class, deck-root or similar? It currently shows up as an anonymous div between the wrapper and the event/widget roots in devtools, and any third-party CSS using a child combinator (#deckgl-wrapper > .deck-events-root) silently stops matching. Nothing in this repo selects on that relationship, but it's a structural change to a public component's DOM, so a named hook is cheap insurance.

Also worth a line in the description: positionChildrenUnderViews emits position: absolute children, which now resolve against this div's content box instead of the wrapper's padding box. That only differs when a caller passes padding or border in style, and the new behavior is the correct one — the children line up with the canvas — but someone compensating for the old offset would see a shift.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in c3e8f25: added deck-root. Also updated the PR description to explain the extra DOM level’s effect on direct-child selectors and the alignment change for view children when the wrapper has padding or borders. Thanks for pointing these out.

Comment thread test/modules/react/deckgl.spec.ts Resolved
Comment thread test/modules/react/deckgl.spec.ts Resolved
@greptile-apps

greptile-apps Bot commented Sep 23, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

@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

Reviewed by Cursor Bugbot for commit 9753bcd. Configure here.

Comment thread modules/react/src/deckgl.ts Resolved
@chrisgervang
chrisgervang merged commit c55cce0 into visgl:master Sep 30, 2026
8 checks passed
@chrisgervang chrisgervang added this to the v9.4 patch releases milestone Oct 4, 2026
lukasmasuch added a commit to streamlit/streamlit that referenced this pull request Oct 7, 2026
## Describe your changes

Pydeck tooltips sit on the cursor again. deck.gl 9.4 places them by
subtracting `.deck-widgets-root` from the canvas, and that root was laid
out one chart height below the map, so the tooltip rendered above the
pointer.

The chart container stretches `.deck-widgets-root` over the canvas
(`position: absolute; inset: 0; pointer-events: none`). Those are the
same properties as the deck.gl fix that is merged but not in a release
yet
([visgl/deck.gl#10724](visgl/deck.gl#10724)).
Downgrading `@deck.gl/*` from 9.4.0 to 9.3.11 would drop the rest of the
9.4 fixes, and pinning only core or only react breaks their peer ranges.
The rule does not use `!important`, so the same inline styles win when
they ship.

## GitHub Issue Link (if applicable)

- Closes #17309

## Testing Plan

- No frontend unit test: jsdom's mocked DeckGL never mounts
`.deck-widgets-root`, so it cannot reproduce the offset.
- [x] E2E Tests:
`e2e_playwright/st_pydeck_chart_test.py::test_pydeck_tooltip_stays_near_cursor`
checks that the tooltip origin stays within 16px of the cursor and that
the widget root is not the hit target. Firefox is skipped because CI
never mounts the deck tooltip there; Chromium and WebKit still run it.
- Manual: default height, `height=250`, `height="stretch"`, and
fullscreen all kept the tooltip on the cursor. Pan and Mapbox zoom still
receive clicks.
@chrisgervang chrisgervang mentioned this pull request Oct 7, 2026
53 of 66 tasks
chrisgervang pushed a commit that referenced this pull request Oct 22, 2026
@brandon-julio-t
brandon-julio-t deleted the fix/react-widget-root-layout branch October 23, 2026 09:50
@chrisgervang

Copy link
Copy Markdown
Collaborator

Released in deck.gl 9.4.1. Thanks @brandon-julio-t!

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] React tooltips are positioned above the map by unpositioned widget root

3 participants