Conversation
it fixes the types. Also: it removes the need to fix the value on the first load (isInitialized state)
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors how column widths are clamped and adjusted by introducing a reusable clamp callback, updates the width adjustment helper to use clamp instead of a raw minWidth, and adds a test to verify loaded widths are clamped when reading from localStorage.
- Extracted and reused a
clampfunction in the column states provider. - Updated
adjustMeasuredWidthsto accept aclampcallback and removed itsminWidthparameter. - Added parameterized tests in
ColumnHeader.test.tsxto ensure loaded widths respectminWidth.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/hooks/useColumnStates.tsx | Introduced clamp, replaced direct minWidth logic, and updated callback dependencies |
| src/helpers/width.ts | Changed adjustMeasuredWidths signature to use clamp and adjusted width math accordingly |
| src/components/ColumnHeader/ColumnHeader.test.tsx | Added parameterized test cases for clamped localStorage widths |
Comments suppressed due to low confidence (2)
src/hooks/useColumnStates.tsx:36
- [nitpick] Either implement validation logic for
availableWidthor remove this TODO comment to keep the codebase clean.
// ^ TODO: add a validation for availableWidth?
src/components/ColumnHeader/ColumnHeader.test.tsx:73
- The test uses
it.for, which is not a valid Jest function. Replace it withit.each(ortest.each) for parameterized tests.
it.for([
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.
Clamp when loading widths from localstorage + when setting a width in the adjustment algorithm.
Also: a small refactoring to simplify the code