DataGrid: collapsible plugin (row truncation + expand toggles)#58
Open
bemky wants to merge 5 commits into
Open
DataGrid: collapsible plugin (row truncation + expand toggles)#58bemky wants to merge 5 commits into
bemky wants to merge 5 commits into
Conversation
Add an opt-in collapsible plugin for the virtualized DataGrid, modeled on the Table collapsible plugin but adapted to virtualization. Rows are grouped by a key or key function; each group gets a full-width header row that toggles its members open/closed. Virtualization integration: the group structure is the source of truth, and the currently-visible entries (always-visible headers + expanded members) are projected onto grid.rows. The existing rowGeometry/updateWindow/scrollbar pipeline consumes grid.rows unchanged, so a collapsed group contributes only its header's height to the total extent. Toggling re-projects, repoints rowGeometry.elements at the new array, and calls updateWindow(). No DataGrid core changes; everything is done via the same lifecycle/hook points the sibling resizable/reorderable plugins use. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The first cut implemented group-by row collapsing; the intended feature is the DataGrid counterpart of the Table collapsible plugin: collapseTo sets a height budget for rows, overflowing cell content is truncated behind a per-cell toggle, and expanding sizes the row to the cell's full content via --expandTo. Expanded state lives on the persistent DataGridRow controller (elements are pooled), and height changes flow through the grid's existing measure/reflow pipeline so windowing and the scroll extent stay correct. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A cell's border-bottom sits at the cell's box bottom, which no longer coincides with the visible row edge once collapsible clamps and clips rows. An inset box-shadow on the row element paints at the row's used box, so the line survives truncation/expansion with no layout impact. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
With the clamp on the row, the row's overflow clip sat exactly on the cells' bottom edge and sheared off per-cell decorations there (the demo's border-bottom grid lines). Cells already clip their own content (overflow: hidden in core styles), and the row's track follows the tallest clamped cell — so clamping only the cells yields the same truncation while keeping the visible row edge inside each cell's box. Reverts the demo's row-shadow workaround in favor of plain cell borders. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cells have a definite grid-column but an auto grid-row, so a prepended overlay child (e.g. the collapsible plugin's toggle, which occupies row 1 at its column) makes auto-placement bump the colliding cell to row 2. Pinning cells to row 1 keeps overlays and cells coexisting in the single row track. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
collapsibleplugin for the virtualizedDataGrid(and subclasses likeDataSpreadsheet) — the windowed counterpart of the Tablecollapsibleplugin, with the same semantics:collapseTo(any valid CSS size, defaultauto) sets a height budget for rows viamax-height: var(--expandTo, var(--collapseTo)).collapsedattribute; each overflowing cell gets a gradient chevron toggle (same affordance as Table's).--expandToon the row element; the collapse toggle reverses it.Like the sibling
resizable/reorderableDataGrid plugins, it is not auto-included — consumers opt in withDataGrid.include(collapsible)/DataSpreadsheet.include(collapsible).Virtualization integration
The tricky part is that DataGrid pools/recycles row and cell elements and drives windowing off measured heights. The plugin leans on the existing pipeline instead of adding geometry code:
--expandTo) resizes the element, which the grid's own row ResizeObserver already turns intomeasure()→reflow()— offsets, the mounted window, and the body scroll extent update for free.DataGridRowcontroller (row.expandedColumns, a Set of columns), never on pooled elements. The live cell is re-resolved on every pass viarow.cellOf(column), and measured heights already travel with controllers — so an expanded row scrolled out of the window keeps its height and restores its expansion (and toggles) when it scrolls back in, and expansion survivessortRows/splices.checkRowCollapse) is idempotent: it always rebuilds toggles/attributes from controller state, so it can run on every resize (content rendering in, column resize rewrapping text,--expandTochanging).collapsed/collapse-toggleattributes on acquire, sinceunmount()only clears style/class.position: sticky+ the cell'sleft; toggle pointerdown/mousedown are stopped so clicking one doesn't start a DataSpreadsheet selection.Verified
Drove the
data-spreadsheetdemo (872 rows,collapseTo: '60px', multi-line Awards column) headlessly: truncation + toggles on load; expand grows the row 60→192px with the body scroll height growing by exactly the delta; scroll-away-and-back restores expansion on the recycled element; collapse reverts; column resize re-checks truncation;sortRowskeeps expanded heights with their rows; toggle clicks don't trigger selection; no console/ResizeObserver errors.🤖 Generated with Claude Code