Repository navigation
feat: autoExpand option to grow the sheet on paste / autofill overflow - #149
Merged
Merged
Conversation
`options.autoExpand` ('none' | 'vertical' | 'horizontal' | 'both', default
'none') lets a paste or an autofill that runs past the last row/column append
the missing rows/columns instead of clipping them, capped by
limits.maxRows / maxCols.
- engine: Sheet.autoExpand; copy / copyAsync / move / writeRawCellMatrix and
Autofill grow the sheet first. New BATCH history so the growth and the write
undo/redo as one step; the growth is rolled back if the operation is refused
(e.g. by a merge).
- react-core: while dragging the autofill handle, ghost rows/columns are
rendered past the edge (as real table rows/cells, so sticky headers stay) so
the drag can reach cells that don't exist yet. A paste that grew the sheet
scrolls the pasted corner into view.
- fix: releasing an autofill drag over a ScrollHandle submitted the fill twice
(two undo steps); StoreObserver's mouseup is now the only submitter.
- docs, storybook story (Restriction/AutoExpand), jest + e2e specs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 of 3 tasks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The autoExpand ghost area is now drawn outside the grid — portaled to <body>, positioned fixed right past the last row/column (only once that edge is scrolled into view) — instead of as extra table rows inside the scroll area. Cells in the fill target are highlighted; StoreObserver doesn't edge-scroll while the pointer is over the ghost layer. Reverts the in-table ghost rendering and the virtualize() "scrolled past the content" tweaks it needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…autofill Replaces the outside-the-sheet ghost layer with provisional ghost rows/columns rendered inside the grid (as table rows/cells, so sticky headers stay): - While the fill drag's pointer is past the grid content's edge (the whitespace of a larger box, or outside it) and the grid is scrolled to that edge, add one ghost row/col at a time, faster the further past the edge (200ms → 20ms). - Ghosts are display-only (no sheet change, no history); releasing grows the sheet up to the reached row/col in one undo step, unreached ghosts vanish. - The target follows the last ghost while past the edge, the grid stays pinned to that edge as it grows, and growth stops once the pointer is back over a cell. The edge ScrollHandle no longer snaps the target back to the last real row/col there. - An autofill that grew the sheet scrolls the filled corner into view. - Storybook AutoExpand story: limits raised to 1000 rows x 100 cols. Co-Authored-By: Claude Opus 5.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
options.autoExpand—'none' | 'vertical' | 'horizontal' | 'both'(default'none', i.e. current behavior). When a paste or an autofill runs past the last row/column, the sheet appends the missing rows/columns instead of clipping the overflow.copy/copyAsync/move/writeRawCellMatrix).autoInsertRow-style, but provisional): while the fill drag's pointer is past the grid content's edge — in the whitespace of a larger box or outside it — and the grid is scrolled to that edge, provisional ghost rows/columns are added one at a time, faster the further past the edge (200ms → 20ms). They're display-only (no sheet change, no history); releasing grows the sheet up to the reached row/column, unreached ghosts vanish. Growth stops when the pointer is back over a cell.limits.maxRows/maxCols; the rest is still clipped.BATCHhistory entry. If the operation is refused after growing (e.g. a move cutting through a merge), the growth is rolled back.Implementation notes
Sheet.autoExpand,getAutoExpansion(),withAutoExpand()/withAutoExpandAsync(), history batching in_pushHistory; undo/redo switch extracted into_undoHistory/_redoHistorysoBATCHcan recurse.Autofillclamps the drag target to what the sheet can grow to.Tabular): ghost rows/cols are rendered as real table rows/cells (.gs-ghost-cell,.gs-ghost-th) so sticky headers and column alignment work;virtualize()keeps the trailing rows/cols rendered when scrolled past the content. While growing, the target follows the last ghost and the grid stays pinned to that edge;StoreObserver/ScrollHandleedge auto-scroll no longer snap the target back to the last real row/col there.ScrollHandlesubmitted the fill twice (two undo steps).StoreObserver's capture-phase mouseup is now the only submitter, as its comment already intended.Limitations
Test plan
packages/engine/src/auto-expand.spec.ts(directions, limits, BATCH undo/redo, writeRawCellMatrix, move, autofill, rollback on refused op) — engine suite 78/78e2e/auto-expand.spec.ts(paste grow + undo,noneclips without scrolling,verticalonly, grown cells scrolled into view; autofill: provisional rows held past the edge then committed in one undo, vanish when dragged back, keep growing when leaving an enlarged box before its whitespace fills (down/right), stop once the pointer is back over a cell)Restriction/AutoExpand(mode switcher, resizable, centered, limits 1000 × 100)🤖 Generated with Claude Code