feat(table): apply column widths via CSS variables during resize#10267
feat(table): apply column widths via CSS variables during resize#10267coolassassin wants to merge 2 commits into
Conversation
Update column widths imperatively on the table root during drag so cells read from CSS custom properties instead of inline layout styles. Commit widths on resize end with a single relayout, and flush onResize when the drag finishes. Co-authored-by: Cursor <cursoragent@cursor.com> � Conflicts: � packages/react-aria/src/table/useTableColumnResize.ts
Add shared test utilities for CSS variable column widths and update table resizing tests to assert pixel widths without relying on inline style.width. Co-authored-by: Cursor <cursoragent@cursor.com>
7faeb43 to
88573e0
Compare
snowystinger
left a comment
There was a problem hiding this comment.
This is definitely ambitious and an interesting idea. A couple of big comments. I'm not sure it's best to act on them yet however, I think the rest of the team should discuss it. If you would like to help with that discussion, a write up of your plan would be the most useful. I would start with the RFC template https://github.com/adobe/react-spectrum/blob/main/rfcs/README.md as noted in this README, this change would fall into the category of substantial.
| renderDropIndicator?: (target: ItemDropTarget) => ReactNode | ||
| ): ReactNode { | ||
| let layoutInfo = reusableView.layoutInfo!; | ||
| let useColumnCSSVariables = layoutInfo.type === 'column' || layoutInfo.type === 'cell'; |
There was a problem hiding this comment.
This (all these lines) are much too specific to tables to go into Virtualizer
| className?: string; | ||
| children: ReactNode; | ||
| /** When true, horizontal positioning uses CSS custom properties instead of inline styles. */ | ||
| useColumnCSSVariables?: boolean; |
|
|
||
| for (let column of columns) { | ||
| let width = columnWidths.get(column.key) ?? 0; | ||
| root.style.setProperty(getColumnWidthVarName(column.index), `${width}px`); |
There was a problem hiding this comment.
stately doesn't do anything with dom if at all possible, it should be agnostic of the environment
Summary
During column drag, table column widths are applied imperatively as CSS custom properties on the table root (
--col-N-width,--col-N-start,--table-total-width). Cells and columns read horizontal size from those variables instead of inlinewidth/leftfrom the virtualizer layout. React state and virtualizer relayout run once onendResize, not on every pointer move.Before:
https://github.com/user-attachments/assets/ed9653bd-18bc-4529-8cb6-1eeeafdf1adf
After:
https://github.com/user-attachments/assets/43daf13c-3181-4b76-b449-063c4c9ef44b
✅ Pull Request Checklist:
📝 Test Instructions:
Automated
Manual
TableView/ResizableTableContainer(many columns, virtualized if possible).react-aria-componentsTableinsideResizableTableContainer(native table + virtualized table if available).onResize/onResizeEndstill fire with expected values.🧢 Your Project:
dxFeed (Devexperts) internal projects