Skip to content

[Bug] React tooltips are positioned above the map by unpositioned widget root #10723

Description

@brandon-julio-t

Description

In React DeckGL, the .deck-widgets-root element is an unpositioned sibling after .deck-events-root. It falls below the canvas in normal document flow. TooltipWidget.onHover() subtracts that root's offset through WidgetManager.getCanvasBounds(), but the tooltip's absolutely positioned ancestors use the outer DeckGL wrapper as their containing block. The resulting tooltip can be placed above the map.

Reproduced with deck.gl 9.4.0 and current master (7fa7dc7) in headless Chromium on Linux. No widget stylesheet is imported.

Expected behavior

The built-in getTooltip tooltip should appear at the picked canvas position, including after resizing the React component.

Steps to reproduce

Render the following React component, then hover over the red point in the center:

import DeckGL from '@deck.gl/react';
import {ScatterplotLayer} from '@deck.gl/layers';

<DeckGL
  width={400}
  height={300}
  initialViewState={{longitude: 0, latitude: 0, zoom: 1}}
  controller
  getTooltip={({object}) => object ? 'Hovered point' : null}
  layers={[
    new ScatterplotLayer({
      id: 'point',
      data: [{position: [0, 0]}],
      getPosition: d => d.position,
      getRadius: 20,
      radiusUnits: 'pixels',
      getFillColor: [255, 0, 0],
      pickable: true
    })
  ]}
/>

The tooltip text exists in the DOM, but its vertical position is above the map. The widget root has zero height and starts below the event root.

A browser regression test on current master with a 200×100 canvas at page offset (40, 60), hovering at canvas coordinate (50, 25), gets tooltip top -15px instead of 85px. Anchoring the React-owned widget root with position: absolute; inset: 0; pointer-events: none restores the expected coordinates and allows pointer hit testing through empty overlay space.

Environment

  • Framework: deck.gl 9.4.0; also reproduced against master 7fa7dc7
  • Browser: Chromium 147 (Playwright)
  • OS: Linux ARM64
  • Flavor: React

Validation / proposed fix

  • Reproduce against current master in a real browser layout.
  • Add a regression test that fails on the current code.
  • Verify a React widget-root layout fix for initial positioning, resize, and pointer hit testing.

The focused fix is in #10724.

Before / after recording

The left pane uses upstream master with the widget root unpositioned; the right pane uses the PR fix. Both run the same standalone scatterplot. The recording hovers the left point first, then the right point twice.

tooltip-before-after.webm

Screenshot while hovering the fixed pane:

Before and after: fixed tooltip visible at the red point

Fix PR: #10724.

Static wrapper layout

The PR also keeps an internal positioned container independent of the outer wrapper’s user-configurable flow style. This preserves canvas and root-level widget placement with style={{position: "static"}}. The comparison below shows the original PR implementation (left) and the updated fix (right); the dashed outline marks the requested wrapper bounds.

Static wrapper layout before and after

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions