Skip to content

fix(table-core): include defaultColumn in memoDeps for column, header, and sizing computations - #6587

Open
lx3133584 wants to merge 1 commit into
TanStack:mainfrom
lx3133584:fix/default-column-memo-deps
Open

fix(table-core): include defaultColumn in memoDeps for column, header, and sizing computations#6587
lx3133584 wants to merge 1 commit into
TanStack:mainfrom
lx3133584:fix/default-column-memo-deps

Conversation

@lx3133584

@lx3133584 lx3133584 commented Sep 9, 2026

Copy link
Copy Markdown

Fixes #5275

🎯 Changes

When a table is constructed, constructColumn merges defaultColumn into each column's columnDef. However, the memoized APIs across core features:

  • table_getAllColumns
  • table_getAllFlatColumns
  • table_getAllFlatColumnsById
  • table_getAllLeafColumns
  • column_getFlatColumns
  • column_getLeafColumns
  • table_getHeaderGroups
  • header_getLeafHeaders
  • header_getContext
  • column_getSize
  • header_getSize
  • header_getStart
  • table_getColumnOffsets
  • column_getIsVisible
  • table_getVisibleFlatColumns
  • table_getVisibleLeafColumns

only included table.options.columns in their memoDeps, omitting table.options.defaultColumn.

As a result, when defaultColumn was updated dynamically via table.setOptions(...) (such as in an effect or upon state changes), the column tree, headers, and sizing were not invalidated and continued to return stale definitions and sizes.

This PR adds defaultColumn to memoDeps across coreColumnsFeature, coreHeadersFeature, columnSizingFeature, and columnVisibilityFeature, and adds unit tests covering defaultColumn updates via setOptions.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm test and pnpm test:e2e, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes

    • Updated column, header, sizing, and visibility calculations when default column settings change.
    • Changes to default column metadata now appear consistently across columns and headers.
    • Updated default column sizes now correctly refresh column and header sizing.
  • Tests

    • Added coverage for changes to default column metadata and sizing.

…, and sizing computations

Co-Authored-By: Claude Code <noreply@anthropic.com>
Signed-off-by: Liang Xu <lx3133584@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: b0ff8d2c-a32a-4c4a-921b-723d30d5aa57

📥 Commits

Reviewing files that changed from the base of the PR and between 36733a3 and 2af676e.

📒 Files selected for processing (8)
  • .changeset/fix-default-column-memo-deps.md
  • packages/table-core/src/core/columns/coreColumnsFeature.ts
  • packages/table-core/src/core/headers/coreHeadersFeature.ts
  • packages/table-core/src/features/column-sizing/columnSizingFeature.ts
  • packages/table-core/src/features/column-visibility/columnVisibilityFeature.ts
  • packages/table-core/tests/unit/core/columns/coreColumnsFeature.utils.test.ts
  • packages/table-core/tests/unit/core/headers/coreHeadersFeature.utils.test.ts
  • packages/table-core/tests/unit/features/column-sizing/columnSizingFeature.utils.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds defaultColumn to memoization dependencies across core column, header, sizing, and visibility APIs. Regression tests verify metadata and size updates after table.setOptions replaces defaultColumn.

Changes

Default column memoization

Layer / File(s) Summary
Core column and header memo dependencies
packages/table-core/src/core/columns/coreColumnsFeature.ts, packages/table-core/src/core/headers/coreHeadersFeature.ts
Core column and header computations now include defaultColumn in their memoization dependencies.
Sizing and visibility memo dependencies
packages/table-core/src/features/column-sizing/columnSizingFeature.ts, packages/table-core/src/features/column-visibility/columnVisibilityFeature.ts
Sizing, offset, and visibility computations now recompute when defaultColumn changes.
Regression tests and release metadata
packages/table-core/tests/unit/core/columns/coreColumnsFeature.utils.test.ts, packages/table-core/tests/unit/core/headers/coreHeadersFeature.utils.test.ts, packages/table-core/tests/unit/features/column-sizing/columnSizingFeature.utils.test.ts, .changeset/fix-default-column-memo-deps.md
Tests verify updated column metadata, header metadata, and column sizes after defaultColumn changes. The changeset declares a patch release.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 2af67

Dynamic defaultColumn updates now refresh derived column, header, visibility, sizing, and offset values, including rendered sizes. Regression coverage verifies the updated metadata and sizing behavior, with no remaining merge-blocking risk identified.

Suggested reviewers: kevinvandy

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: adding defaultColumn to memoization dependencies for column, header, and sizing computations.
Description check ✅ Passed The description explains the bug, implementation, tests, checklist status, and release impact. It follows the required template.
Linked Issues check ✅ Passed The changes satisfy issue [#5275] by invalidating sizing and related memoized computations when defaultColumn changes through table.setOptions. Regression tests verify updated sizes and definitions.
Out of Scope Changes check ✅ Passed All code, tests, and the changeset address defaultColumn memoization and its dynamic updates. No unrelated changes are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 7…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@KevinVandy

Copy link
Copy Markdown
Member

This has been proposed a few times lately, but I think it would be too large of a breaking change and hurt performance for most tables, especially in react. This means that it would be expected for everyone to give their defaultColumn option a stable reference with useMemo, otherwise, all the calculations would be constantly re-firing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A table doesn't get updated when a defaultColumn changes

2 participants