Constrain autofill to a single axis (vertical or horizontal)#82
Conversation
Verification: verify:selfResult: ✅ PASS in 104.5s
Verification: verify:integrationResult: ✅ PASS |
Previously computeAutofillRange created a bounding box that could extend in both row and column directions simultaneously. Now the target is clamped to the dominant axis — whichever direction the drag extends furthest from the source edge — matching Google Sheets behaviour. Ties favour vertical. Co-Authored-By: Claude Opus 4.6 <[email protected]>
📝 WalkthroughWalkthroughThe pull request modifies autofill behavior for fill-handle drag operations, constraining expansion to a single dominant axis (vertical or horizontal) rather than allowing unrestricted rectangular expansion. The dominant axis is determined by which direction extends farthest from the source, with ties favoring vertical. Updates span design documentation, core implementation, and test coverage. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/sheets/test/sheet/autofill.test.ts (1)
42-55: Minor naming inconsistency in test description.The test name says "vertical wins on tie", but this scenario isn't actually a tie—vertical distance is 2 vs horizontal distance 1. Consider renaming to better reflect what's being tested:
- it('constrains autofill to single axis (vertical wins on tie)', async () => { + it('constrains autofill to single axis (diagonal target)', async () => {Alternatively, to truly test the tie-breaker behavior, you could use a target where both distances are equal (e.g.,
{ r: 2, c: 2 }for a single-cell source at A1).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/sheets/test/sheet/autofill.test.ts` around lines 42 - 55, The test titled "constrains autofill to single axis (vertical wins on tie)" is misleading because the target { r: 3, c: 2 } is not a tie (vertical distance 2 vs horizontal 1); either rename the test to reflect vertical dominance (e.g., "constrains autofill to single axis (vertical wins)"), or change the target to a true tie (e.g., use sheet.autofill({ r: 2, c: 2 })) so it actually exercises the tie-breaker; update the test title or the autofill target accordingly in the it(...) block that constructs Sheet and calls sheet.autofill.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/sheets/test/sheet/autofill.test.ts`:
- Around line 42-55: The test titled "constrains autofill to single axis
(vertical wins on tie)" is misleading because the target { r: 3, c: 2 } is not a
tie (vertical distance 2 vs horizontal 1); either rename the test to reflect
vertical dominance (e.g., "constrains autofill to single axis (vertical wins)"),
or change the target to a true tie (e.g., use sheet.autofill({ r: 2, c: 2 })) so
it actually exercises the tie-breaker; update the test title or the autofill
target accordingly in the it(...) block that constructs Sheet and calls
sheet.autofill.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 97af10de-867b-4cad-bd67-1ae5c12be89f
📒 Files selected for processing (4)
docs/design/frontend.mddocs/design/sheet.mdpackages/sheets/src/model/worksheet/clipboard.tspackages/sheets/test/sheet/autofill.test.ts
Summary
Previously computeAutofillRange created a bounding box that could extend in both row and column directions simultaneously. Now the target is clamped to the dominant axis — whichever direction the drag extends furthest from the source edge — matching Google Sheets behaviour.
Why
Both google sheet and excel supports to autofill vertical or horizontal.
This change will handle number-autofill case easily (future work). It does not just fill repeatly, based on Ordinary Least Squares(OLS).
Linked Issues
Fixes #
Verification
CI automatically posts a verification summary comment on this PR with
per-lane results for both
verify:selfandverify:integration.Skip reason (if applicable):
Risk Assessment
Notes for Reviewers
Summary by CodeRabbit
Documentation
Bug Fixes
Tests