fix: handle division by zero in column resize handler when startSize is 0#6215
Conversation
…is 0 When a column is resized to 0 width (with minSize: 0), the resize handler produces NaN from deltaOffset / startSize division by zero. This NaN propagates into columnSizing state, making the column permanently stuck. Two fixes applied: - Guard deltaPercentage calculation against startSize === 0 - Use absolute deltaOffset for new size when headerSize is 0, since percentage-based calculation (headerSize * deltaPercentage) always yields 0 when starting from zero Closes TanStack#6209
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughFixed division-by-zero errors in column resize calculations by capturing the starting size and falling back to alternative sizing logic when initial size is zero or negative. Prevents columns resized to zero width from becoming unresizable. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
|
View your CI Pipeline Execution ↗ for commit 60f5266
☁️ Nx Cloud last updated this comment at |
Summary
Fixes #6209
When a column's
minSizeis set to0and the column is resized down to 0px width, the resize handler divides by zero (deltaOffset / startSize), producingNaN. ThisNaNpropagates into thecolumnSizingstate, making the column permanently stuck at 0 width.Changes
columnResizingFeature.utils.ts— two guards inupdateOffset:deltaPercentagecalculation: WhenstartSizeis0, return0instead ofdeltaOffset / 0(which producesInfinity/NaN)headerSizeis0, use absolutedeltaOffset(distributed equally across leaf columns) instead of the percentage-based formulaheaderSize + headerSize * deltaPercentage, which always yields0when starting from zerocolumnResizingFeature.utils.test.ts:deltaPercentageis a finite number whenstartSizeis zero (noNaN/Infinity)mouseupcleanup inonChangemode test that was leaking event listenersremoveEventListenercall count expectation (4→2) that was inflated by leaked listeners from prior testSummary by CodeRabbit
Bug Fixes
Tests