-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: apply full width automatically for DataTable #18357
Conversation
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (12/23/24)1 reviewer was added to this PR based on Keith Williams's automation. "Add ready-for-e2e label" took an action on this PR • (01/02/25)1 label was added to this PR based on Keith Williams's automation. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
7c6cee6
to
b3812fc
Compare
} | ||
return colSizes; | ||
}, [table.getFlatHeaders(), table.getState().columnSizingInfo, table.getState().columnSizing]); | ||
const columnSizingVars = useColumnSizingVars({ table }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracted as a separate file for readability
@@ -543,6 +542,11 @@ function UserListTableContent() { | |||
} | |||
}; | |||
|
|||
if (!isSuccessAttributes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is to avoid flickering (attributes are fetched at the similar timing as the table data, anyway)
5cd74fa
to
8d0090e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Screen.Recording.2025-01-01.at.6.56.26.PM.mov
In mobile view shouldn't all columns be horizontally scrollable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge conflicts
Hey @Udit-takkar , that's a good point. Currently the member column is pinned. I'll think about how/when to disable pinning feature for small viewports, and apply the change here soon. update: fixed 10ea635 |
E2E results are ready! |
* feat: apply full width automatically for DataTable * change implementation * load all columns of insights routing table at the same time * update team member list * sticky columns for >= sm * fix type error --------- Co-authored-by: Udit Takkar <[email protected]>
What does this PR do?
This PR improves DataTable to fill the full width.
Details
How we calculate the default width of columns in DataTable:
size
values as a part of ColumnDef. Example:cal.com/packages/features/users/components/UserTable/UserListTable.tsx
Line 203 in d71b9e2
getSize()
function and its default value (https://tanstack.com/table/latest/docs/api/features/column-sizing#getsize)When browser's width is too large or there is not enough columns, the DataTable doesn't fill the full width. It used to do so, but not anymore since we've applied
flex
to<TableRow />
for the following reasons:This PR fixes the logic to calculate the column widths by increasing them a bit more if the calculated total widths doesn't fill the container's clientWidth. They are also re-calculated as browser resizes.
Screenshot.2024-12-24.at.16.55.12.mp4
New behaviors:
1. initially full width
2. still full width on browser resize (but will have horizontal scroll if browser width is too small)
3. it adjusts other columns' widths automatically when resizing a column
4. it saves only intentionally resized columns in localStorage
(The recalculation of column sizes on window resize is debounced for better performance.)
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
If you already have resized columns, it may affect the result. So it's better to delete data from localStorage before testing. Delete all the keys starting with
data-table-column-sizing-
.DataTable should look good in the following pages:
Checklist