Skip to content

Sub-cell hit testing API: clickable zones within cells #4

@witqq

Description

@witqq

Summary

Current HitTestResult resolves to cell-level granularity only: { region, row, col }. There is no mechanism for identifying sub-cell interactive elements (expander icons, sort buttons, links, action buttons within a cell).

Current State

  • EventTranslator emits cellClick(row, col) — no sub-cell info
  • HitRegion has: cell, header, header-sort-icon, header-filter-icon, row-number, row-group-toggle, corner, outside
  • Header-level sub-elements (sort/filter icons) ARE supported, but only in column headers
  • No API for CellTypeRenderer to declare clickable zones

Proposed API

interface CellHitZone {
  id: string;              // e.g. "expander", "sort-icon", "link", "action-btn"
  x: number;               // relative to cell origin
  y: number;
  width: number;
  height: number;
  cursor?: string;         // CSS cursor on hover
}

interface CellTypeRenderer {
  // ... existing methods ...
  getHitZones?(value: CellValue, cellWidth: number, cellHeight: number, theme: SpreadsheetTheme): CellHitZone[];
}

Events would extend to:

engine.on("cellClick", (row, col, hitZoneId?: string) => { ... });
engine.on("cellHover", (row, col, hitZoneId?: string) => { ... });

Motivation

Consumers (e.g., planeta-worktree2) build custom DimensionCellHitTester classes that subscribe to gridMouseDown/gridMouseMove and manually compute hit zones. A native API would make this unnecessary.

Files to modify

  • packages/core/src/types/cell-type-registry.ts — add getHitZones to CellTypeRenderer
  • packages/core/src/events/event-translator.ts — resolve sub-cell zones
  • packages/core/src/types/interfaces.tsCellHitZone, extended event types

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions