Skip to content

fix: include feature default options in useTable's table.options - #6668

Open
victuribdev wants to merge 6 commits into
TanStack:mainfrom
victuribdev:fix-use-table-resolved-options
Open

victuribdev wants to merge 6 commits into
TanStack:mainfrom
victuribdev:fix-use-table-resolved-options

Conversation

@victuribdev

@victuribdev victuribdev commented Nov 21, 2026 •

Copy link
Copy Markdown

🎯 Changes

Fixes #6667

useTable returned options: tableOptions, which overrode the resolved options already spread from ...table, so defaults from getDefaultTableOptions (e.g. columnResizeMode: 'onEnd') were missing on the hook's table but present on row.table. It now returns { ...table.options, ...tableOptions }. tableOptions is still read inside the memo, so the deps stay [table, tableOptions, state] and the returned object still only changes when the caller's options do. Using coreTable.options as suggested in the issue trips react-hooks/exhaustive-deps, and disabling that rule makes the React Compiler lint skip the hook, so I went with this.

Same change in preact-table and octane-table, which had the same pattern. Added a test to react-table and preact-table (fails before, passes after). octane-table has no useTable unit tests, so it's only the source change there.

Ran vitest, eslint and tsc for react-table and preact-table, and vitest for octane-table. I didn't run the full pnpm test / pnpm test:e2e.

✅ 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
    • useTable now exposes resolved feature defaults in table.options, while preserving caller-supplied options when they override those defaults.
    • Added coverage confirming the default column resize mode and that an explicit setting takes effect.

@changeset-bot

changeset-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7d578c7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@tanstack/react-table Patch
@tanstack/preact-table Patch
@tanstack/octane-table Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The React, Preact, and Octane useTable adapters now return options that include feature defaults while preserving caller-supplied values. React and Preact tests check the default and explicit columnResizeMode values. A changeset declares patch releases for all three packages.

Changes: Resolved useTable options

Layer / File(s) Summary
Merge resolved and caller options
packages/react-table/src/useTable.ts, packages/preact-table/src/useTable.ts, packages/octane-table/src/useTable.tsrx, packages/react-table/tests/useTable.test.tsx, packages/preact-table/tests/unit/useTable.test.tsx, .changeset/use-table-resolved-options.md
The three adapters merge table.options with caller-supplied tableOptions, which take precedence. React and Preact tests verify that columnResizeMode defaults to onEnd and reflects an explicit onChange value. The changeset declares patch releases for the three packages.

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

Change: Bug fix

Suggested reviewers: kevinvandy

Merge Risk: Minimal · up to 7d578

useTable now exposes feature defaults in table.options while still honoring caller-provided options. The change is small and tested for React and Preact, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: useTable's table.options now includes feature default options from getDefaultTableOptions. It uses the fix: prefix and states the component and the affected field. The…
Description check Passed The description follows the template sections: Changes, Checklist, and Release Impact. The Changes section gives the cause, the fix, the deps reasoning, the adapters touched, and the tests added. The …
Linked Issues check Passed Issue #6667 requires that table.options from React useTable include feature defaults from getDefaultTableOptions, with user options taking precedence. The reviewed change in `packages/react-tabl…
Out of Scope Changes check Passed All changed files relate to the linked issue. The useTable source changes in react-table, preact-table, and octane-table implement the same fix. The react-table and preact-table test additions verif…
Full details: Title check

Explanation

The title names the main change: useTable's table.options now includes feature default options from getDefaultTableOptions. It uses the fix: prefix and states the component and the affected field. The changeset, source edits in the three adapters, and tests all match this title.

Full details: Description check

Explanation

The description follows the template sections: Changes, Checklist, and Release Impact. The Changes section gives the cause, the fix, the deps reasoning, the adapters touched, and the tests added. The unchecked box for pnpm test and pnpm test:e2e is stated in the text, with the reason that the full suite was not run. The checklist items are filled in consistently with the changeset that was added.

Full details: Linked Issues check

Explanation

Issue #6667 requires that table.options from React useTable include feature defaults from getDefaultTableOptions, with user options taking precedence. The reviewed change in packages/react-table/src/useTable.ts returns options: { ...table.options, ...tableOptions } inside the memo. table.options holds the resolved options after table_setOptions, so the defaults are kept. Spreading tableOptions last keeps caller overrides. The memo dependencies remain [table, tableOptions, state], so the identity behavior described in the issue is preserved. The PR adds a React regression test in packages/react-table/tests/useTable.test.tsx that checks the columnResizeMode default ('onEnd') and the caller override ('onChange'). The issue asks that other adapters be checked. The same change appears in packages/preact-table/src/useTable.ts (with a Preact test) and packages/octane-table/src/useTable.tsrx. Evidence comes from the PR summary and the stated diff; I did not inspect the source files directly. The Octane change has no unit test, which the PR states. The issue does not require one.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the linked issue. The useTable source changes in react-table, preact-table, and octane-table implement the same fix. The react-table and preact-table test additions verify the fix. The changeset .changeset/use-table-resolved-options.md covers the three published packages affected by the fix. No unrelated feature, refactor, or configuration change appears in the summary. Evidence comes from the PR summary and the per-file summaries; I did not inspect the diff hunks directly.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 1cfb2e5 and 7d578c7.

Files selected for processing: 6

  • .changeset/use-table-resolved-options.md
  • packages/octane-table/src/useTable.tsrx
  • packages/preact-table/src/useTable.ts
  • packages/preact-table/tests/unit/useTable.test.tsx
  • packages/react-table/src/useTable.ts
  • packages/react-table/tests/useTable.test.tsx

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

This branch has not been deployed

No deployments
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.

[v9][react] Table returned by useTable has options without feature defaults from getDefaultTableOptions

1 participant