Skip to content

refactor(table): add grouped and pinned column headers to table component#8392

Draft
LWS49 wants to merge 1 commit into
masterfrom
lws49/feat-table-grouped-headers
Draft

refactor(table): add grouped and pinned column headers to table component#8392
LWS49 wants to merge 1 commit into
masterfrom
lws49/feat-table-grouped-headers

Conversation

@LWS49
Copy link
Copy Markdown
Collaborator

@LWS49 LWS49 commented May 19, 2026

Summary

This PR adds support for multi-level grouped headers and pinned (sticky) columns to the table component. It introduces a new header building system that handles complex column hierarchies while maintaining proper column ordering and pinning behavior.

Key Changes

  • New buildHeaderRows function (builder/buildHeaderRows.ts): Core logic that transforms a flat column array into a multi-row header structure, handling:

    • Multi-level column grouping via groupPath property
    • Column pinning to left/right edges with proper reordering
    • Automatic colSpan/rowSpan calculation for group cells
    • Development-time validation (missing widthPx on pinned columns, inconsistent grouping depths, non-contiguous groups)
  • New computePinOffsets function (MuiTableAdapter/gridSxStyles.ts): Calculates sticky positioning offsets for pinned columns (cumulative from left, reverse cumulative from right)

  • Updated MuiTableHeader component: Refactored to render multi-row headers with proper sticky positioning, pin attributes, and sort/filter UI only on leaf cells

  • New useStickyHeaderOffsets hook (MuiTableAdapter/useStickyHeaderOffsets.ts): Dynamically computes top offsets for sticky header rows based on their heights

  • Enhanced ColumnTemplate interface: Added groupPath and pin/widthPx properties to support grouped and pinned columns

  • Updated MuiTableRow component: Added pinned column support with proper sticky positioning and offset calculation

  • New grid styling (gridSxStyles.ts): Comprehensive styling for grouped headers, pinned columns, and their interactions (borders, z-index, sticky behavior)

  • Comprehensive test coverage:

    • 30+ unit tests for buildHeaderRows covering flat/grouped/pinned scenarios and edge cases
    • 10+ integration tests for the full <Table /> component with various configurations

Notable Implementation Details

  • Pinned columns are automatically reordered to appear first (left pins) and last (right pins) regardless of declaration order
  • Pinned columns span all header rows when grouping is present
  • Group cells only appear in non-leaf rows; leaf cells contain the actual column data
  • Sticky header positioning accounts for multi-row headers by computing cumulative heights
  • Development mode includes validation warnings for common configuration errors (non-contiguous groups, inconsistent depths)
  • The maxHeight prop on TableTemplate enables scroll-contained tables with sticky headers

@LWS49 LWS49 changed the title Lws49/feat table grouped headers refactor(table): add grouped and pinned column headers to table component May 19, 2026
@LWS49 LWS49 force-pushed the lws49/feat-table-grouped-headers branch 4 times, most recently from 218771e to 3a8b328 Compare May 19, 2026 15:21
@LWS49 LWS49 force-pushed the lws49/feat-table-grouped-headers branch from 3a8b328 to 4065e11 Compare May 19, 2026 15:32
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.

1 participant