Skip to content

fix: enhance table option merging to preserve static properties#6328

Open
KevinVandy wants to merge 2 commits into
betafrom
fix-solid-merge-props
Open

fix: enhance table option merging to preserve static properties#6328
KevinVandy wants to merge 2 commits into
betafrom
fix-solid-merge-props

Conversation

@KevinVandy

@KevinVandy KevinVandy commented Jun 16, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Updated the table_mergeOptions function to ensure that static options (features, atoms, initialState) are preserved without mutation when merging new options. Added a test to verify that static options remain unchanged after invoking setOptions.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

Summary by CodeRabbit

  • Refactor
    • Reworked internal table option merging to reliably preserve static configuration (including data, features, atoms, and initial state) when options are updated.
  • Tests
    • Added unit tests covering option updates, including scenarios involving getter-based merge behavior and checks for correct object identity.
  • Documentation
    • Updated documentation to clarify how merged option objects restore and preserve static options.

Updated the table_mergeOptions function to ensure that static options (features, atoms, initialState) are preserved without mutation when merging new options. Added a test to verify that static options remain unchanged after invoking setOptions.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ed2d87c2-65a7-4869-9668-60c94c217b1e

📥 Commits

Reviewing files that changed from the base of the PR and between 8af20a5 and c649163.

📒 Files selected for processing (1)
  • packages/table-core/src/core/table/coreTablesFeature.utils.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/table-core/src/core/table/coreTablesFeature.utils.ts

📝 Walkthrough

Walkthrough

table_mergeOptions is rewritten to reconstruct the merged result using Object.create and Object.defineProperties, explicitly pinning features, atoms, and initialState as own property descriptors from the original table.options. table_setOptions is simplified to delegate entirely to table_mergeOptions. A unit test is added with a getter-based merge helper to verify static option identity is preserved.

Changes

Static options preservation in mergeOptions

Layer / File(s) Summary
table_mergeOptions reconstruction and table_setOptions simplification
packages/table-core/src/core/table/coreTablesFeature.utils.ts
Inline docs updated to describe the static-restore requirement. table_mergeOptions rewrites its return to use Object.create/Object.defineProperties, pinning features, atoms, and initialState as own descriptors from the original table.options regardless of what the merge helper returned. table_setOptions removes its post-merge Object.assign preservation step and delegates entirely to table_mergeOptions.
getterOnlyMerge helper and setOptions static-preservation test
packages/table-core/tests/unit/core/table/constructTable.test.ts
Adds a local getterOnlyMerge function that defines lazy getter properties on a target scanning sources last-to-first. A new unit test uses this as mergeOptions, calls table.setOptions, and asserts object identity for data, features, atoms, and initialState.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • TanStack/table#6266: Both PRs change how option objects are produced during mergeOptions/table.setOptions updates to avoid problematic getter/lazy-merge behavior (this PR preserves static data/features/atoms/initialState, related PR switches to flatMerge to prevent getter chaining).

Poem

🐇 Hop hop, the options stay true,
No getter-proxy can sneak on through!
Object.create builds a fresh little nest,
features and atoms pass the identity test.
Static fields pinned with a careful paw—
The rabbit's merge fix has no flaw! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: enhance table option merging to preserve static properties' directly aligns with the main change—rewriting table_mergeOptions to preserve static options (features, atoms, initialState) during merge operations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-solid-merge-props

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 and usage tips.

@nx-cloud

nx-cloud Bot commented Jun 16, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 8af20a5

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 4m 57s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 25s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-16 13:42:44 UTC

@pkg-pr-new

pkg-pr-new Bot commented Jun 16, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table@6328

@tanstack/angular-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table-devtools@6328

@tanstack/lit-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/lit-table@6328

@tanstack/match-sorter-utils

npm i https://pkg.pr.new/TanStack/table/@tanstack/match-sorter-utils@6328

@tanstack/preact-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table@6328

@tanstack/preact-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table-devtools@6328

@tanstack/react-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table@6328

@tanstack/react-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table-devtools@6328

@tanstack/solid-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table@6328

@tanstack/solid-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table-devtools@6328

@tanstack/svelte-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/svelte-table@6328

@tanstack/table-core

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-core@6328

@tanstack/table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-devtools@6328

@tanstack/vue-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table@6328

@tanstack/vue-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table-devtools@6328

commit: c649163

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.

1 participant