Skip to content

perf(grid): hoist secondary click (context menu) and tooltip handling from _GridCell to grid level #1346

Closed

Description

@ZhuchkaTriplesix

Summary

In #983, primary pointer taps and cursor regions were successfully hoisted to grid-level hit-testing, significantly reducing per-cell overhead during scrolling and column-window shifts. However, as explicitly noted in #983 (comment) and #987, secondary-tap (right-click), ContextMenu (from shadcn_flutter), and material.Tooltip handling remained inside each visible _GridCell.

For a standard viewport with 30 visible rows and 20 visible columns (600 visible cells), this mounts:

  • 600 material.Listener(onPointerDown: ...) instances
  • 600 ContextMenu instances (with eager child builders)
  • 600 material.Tooltip instances (each maintaining internal gesture and overlay timers)

This bloats the widget tree with ~4,200 widgets/render objects and retains a dependency on shadcn_flutter inside the hot grid rendering loop (related to Epic #1331).

Proposed Solution

  1. Grid-level right click: Capture secondary pointer down events at the grid gesture layer (GridPointerSelection / grid hit test) and compute _cellAtOffset(offset) on demand.
  2. On-demand ContextMenu: Only instantiate and display the context menu when a cell is actually right-clicked, instead of wrapping every visible cell in a ContextMenu.
  3. Grid-level Tooltip / Cell Popover: Hoist truncated cell tooltip display to the grid level or trigger it via the existing _GridCellPopoverInspector mechanism.
  4. Convert _GridCell to a pure, lightweight leaf widget (Container with padding, border, and Text).

Acceptance Criteria

  • _GridCell does not instantiate per-cell ContextMenu, Listener(onPointerDown), or Tooltip.
  • Right-clicking any cell continues to open the cell context menu at the click position.
  • Hovering over truncated cells continues to show tooltip / value inspection.
  • Frame build time during horizontal window shifts (grid_perf_bench.dart MODE=scroll) shows measurable reduction.

Activity

  1. added
    frontendTheme parser epic label: frontend
    performanceTheme parser epic label: performance
    uiUser interface components and widgets
    data-gridInteractive data grid, cell editor, filtering, groupings
    P2Medium priority / Parity & Refactoring
    on Oct 10, 2026
  2. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Resolved and merged into dev via PR #1473.

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

    P2Medium priority / Parity & Refactoringdata-gridInteractive data grid, cell editor, filtering, groupingsfrontendTheme parser epic label: frontendperformanceTheme parser epic label: performanceuiUser interface components and widgets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions