Skip to content

Fix DataTable tooltip position on paginated pages - #3928

Open
saket3395 wants to merge 1 commit into
plotly:devfrom
saket3395:fix/datatable-tooltip-pagination
Open

Fix DataTable tooltip position on paginated pages#3928
saket3395 wants to merge 1 commit into
plotly:devfrom
saket3395:fix/datatable-tooltip-pagination

Conversation

@saket3395

Copy link
Copy Markdown

Summary

Fixes #1848 — DataTable tooltips render in the wrong position (top-left) on pages other than page 1 when pagination + tooltips are combined.

Root cause: the tooltip row index was resolved from the virtualized (page-local) index in two separate places — once in the cell event handler (cellEvents.ts), and again when matching the tooltip condition/data (tooltip.ts). On page 1 both resolutions happen to agree, hiding the bug. On later pages they diverge, so the tooltip looks up the wrong row.

This ports the fix originally proposed in plotly/dash-table#906 (opened against the standalone dash-table repo before it was merged into dash), applied to the current file paths — the line-level context still matched exactly:

  • components/dash-table/src/dash-table/handlers/cellEvents.ts: handleEnter/handleMove now store the raw virtualized idx in currentTooltip.row, instead of pre-resolving it — consistent with how handleMoveHeader already handles header tooltips.
  • components/dash-table/src/dash-table/derived/table/tooltip.ts: getSelectedTooltip now resolves virtualized.indices[row - offset.rows] once, at lookup time.

As noted on the issue by @alexcjohnson: "should be relatively straightforward to bring it over here and finish it."

Test plan

  • Diffed against dash-table#906 line-by-line — the current code matched the original PR's context exactly, so the port is a faithful line-for-line application, no adaptation needed.
  • Verified handleMoveHeader (unaffected header-tooltip path) already follows the "store raw idx" pattern this PR brings to the row-tooltip path, so the change is internally consistent.
  • Not yet run through the JS build/test suite locally — flagging for maintainer/CI verification. Happy to iterate if CI surfaces anything.

Fixes plotly#1848. Tooltip row index was resolved against the virtualized
(page-local) row twice: once when handling the mouse event, and again
when matching the tooltip condition/data lookup. On page 1 these two
resolutions coincide, masking the bug; on later pages they diverge,
so tooltips render using the wrong row's position/data.

Ports the fix from plotly/dash-table#906 (pre-merge into this repo):
- cellEvents.ts: store the raw virtualized idx in currentTooltip.row
  instead of pre-resolving it, matching how handleMoveHeader already
  behaves for header tooltips.
- tooltip.ts: resolve virtualized.indices[row - offset.rows] once,
  at lookup time in getSelectedTooltip, instead of relying on a
  pre-resolved value.

Manually verified the diff is a faithful port of plotly#906 and consistent
with the surrounding code (handleMoveHeader already stores the raw
idx). Not yet run through the JS build/test suite locally.
@sonarqubecloud

Copy link
Copy Markdown

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.

dashtable with pagination: tooltips appear in wrong place

1 participant