Repository navigation
feat!: resize columns without re-rendering the sheet - #26
Merged
Merged
Conversation
Follow TanStack v9's advice for resizing with columnResizeMode 'onChange'. useSheet's useTable selector leaves out the resize state, Sheet writes --sheet-columns from table.atoms.columnSizing in a layout effect, and only each resize handle subscribes to its column's width. The body no longer needs its memo. BREAKING CHANGE: table.state no longer holds columnSizing or columnResizing, and resizing a column no longer re-renders the component that calls useSheet. Read the widths with table.atoms.columnSizing.get(), or subscribe with Subscribe. Code that reads a width while rendering, such as column.getSize() in your own header or a --sheet-columns you build yourself, has to subscribe to stay current. An app that controls columnSizing through state and onColumnSizingChange still re-renders on every resize, and now its rows do too: pass an external atom in atoms instead, as TanStack's column sizing guide recommends.
4 of 7 tasks
Merged
4 of 7 tasks
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.
Etiquettes of raising a PR
PR reviews are a way to request peers to give feedback on the code that is going
to the mainline. This means, that PR should be in a reviewable state. Please ensure
that the following checkboxes are ticked. If any of them are not ticked, then
the PR is not ready for review
Related issue
Functionalities added or changed
useSheetpassesuseTablea selector that leaves outcolumnSizingandcolumnResizing.Sheetwrites--sheet-columnsfromtable.atoms.columnSizingin a layout effect.Subscribeisland, so its width readout and highlight follow the drag. Keyboard resizing reads the width when the key is pressed.table.stateleaves out, owning the widths with an atom, headless use, API reference),architecture.mdanddecisions.md.Additional info
table.stateno longer hascolumnSizingorcolumnResizing. Read the widths withtable.atoms.columnSizing.get(), or subscribe withSubscribe.useSheet, so your own markup that readsgetSize()while rendering has to subscribe.columnSizingwithstateandonColumnSizingChangestill re-renders on every resize, and now its rows do too. TanStack recommends an external atom inatomsfor owning the widths.decisions.md):() => ({})), because a sheet re-renders for sorting, filters, pinning, visibility and order.Sheetalso sets--sheet-columnswhen it renders, so server-rendered HTML has its column tracks.table, whichuseTablereturns anew on each render, instead of[].Subscribewithtable.store, which TanStack's React Compiler guide says to use in header components.content-visibility: auto, which isn't one of the guide's steps.table.statehas every slice but those two, and that widths and hidden columns the app controls still lay out. Three of them fail onmain.Checklist
Screenshots
Page(s) if applicable
No visual change.