Skip to content

fix(svelte-table): set App* contexts in their own components - #6618

Open
india3Eth wants to merge 1 commit into
TanStack:mainfrom
india3Eth:fix/svelte-app-wrapper-context
Open

india3Eth wants to merge 1 commit into
TanStack:mainfrom
india3Eth:fix/svelte-app-wrapper-context

Conversation

@india3Eth

@india3Eth india3Eth commented Oct 7, 2026 •

Copy link
Copy Markdown

Fixes #6614

🎯 Changes

The App* wrappers from createAppTable called setContext before calling the real component, so it ran in the context of whatever component rendered <table.AppCell>. That works by accident during the parent's first render, but a cell created later (e.g. after toggleVisibility() on a hidden column) throws set_context_after_init with experimental.async, and even without async mode the contexts land in the parent's context map.

AppTable.svelte, AppCell.svelte and AppHeader.svelte now set their context themselves while they initialize (AppTable gets table as a prop for that), and the wrappers only add props. The context keeps the initial prop value, as before.

Test: a fixture renders the four wrappers next to a probe that reads the three context keys. On main the probe sees all of them; now it sees none and the wrapper children still read their contexts. I also checked the issue's case locally with a throwaway async-mode config (hidden column, then toggleVisibility()): set_context_after_init before, renders after. svelte-table tests, svelte-check, eslint and prettier pass.

✅ 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
    • Fixed context initialization errors in async mode when table cells are created later. Table, cell, header, and footer contexts are now available within their respective components. This preserves the existing rendering behavior while allowing these components to initialize their contexts at the right time.

@changeset-bot

changeset-bot Bot commented Oct 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f2ce8fa

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

This PR includes changesets to release 1 package
Name Type
@tanstack/svelte-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 Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: TanStack/table/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6ee6fe42-4460-4653-970e-61e7b49dfd0d
📥 Commits

Reviewing files that changed from the base of the PR and between 6aa0d74 and f2ce8fa.

📒 Files selected for processing (8)
  • .changeset/svelte-app-wrapper-context.md
  • packages/svelte-table/src/AppCell.svelte
  • packages/svelte-table/src/AppHeader.svelte
  • packages/svelte-table/src/AppTable.svelte
  • packages/svelte-table/src/createTableHook.svelte.ts
  • packages/svelte-table/tests/fixtures/HookContextProbe.svelte
  • packages/svelte-table/tests/fixtures/HookContextScope.svelte
  • packages/svelte-table/tests/rendering.test.ts

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


📝 Walkthrough

Walkthrough

The Svelte table app components now set table, cell, and header contexts during their own initialization. Wrappers pass the relevant values to those components. A rendering test checks wrapper output and context scope.

Changes

Svelte wrapper context

Layer / File(s) Summary
Component-owned context setup
packages/svelte-table/src/AppTable.svelte, packages/svelte-table/src/AppCell.svelte, packages/svelte-table/src/AppHeader.svelte, packages/svelte-table/src/createTableHook.svelte.ts, .changeset/svelte-app-wrapper-context.md
The app components set table, cell, and header context using untrack. The wrappers pass the corresponding values as component props instead of calling setContext. The changeset records a patch release for @tanstack/svelte-table.
Context scope rendering test
packages/svelte-table/tests/fixtures/HookContextProbe.svelte, packages/svelte-table/tests/fixtures/HookContextScope.svelte, packages/svelte-table/tests/rendering.test.ts
The fixture renders app-scoped table, cell, header, and footer components, then probes context outside the wrappers. The test checks wrapper content and verifies that the probe output is empty.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: kevinvandy

Merge Risk: ⚪ Minimal · up to f2ce8

The change moves context setup into the Svelte app components, so the contexts are no longer written to the parent component. No merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: moving App* context setup into the corresponding Svelte components.
Description check ✅ Passed The description explains the bug, motivation, implementation, test coverage, and release impact. It includes all required template sections and completed checklist items.
Linked Issues check ✅ Passed Issue [#6614] requires AppTable, AppCell, AppHeader, and AppFooter to set context in their own components. AppTable.svelte, AppCell.svelte, and AppHeader.svelte now call setContext dur…
Out of Scope Changes check ✅ Passed The changes stay within issue [#6614]. The changeset documents the published fix. The fixture and rendering test validate context scope and wrapper behavior. No unrelated source, test, or configuratio…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (6 skipped: 6 …
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · 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

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

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.

[svelte] createTableHook: App* wrappers call setContext in the parent's component context (set_context_after_init when showing a column)

1 participant