Skip to content
Source
Sign inSign up
TanStack/table

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

Mergedindia3Eth(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/6618/headmerged by KevinVandy

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.
    1. changeset-bot[bot](GitHub profile, opens in a new tab)commented

      🦋 Changeset detected

      Latest commit: ff999f71e729bf87ab376e5f526761cb7ed6823e

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

      This PR includes changesets to release 1 package
      NameType
      @tanstack/svelte-tablePatch

      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

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Important

      Review skipped

      Review was skipped as selected files did not have any reviewable changes.

      ⚙️ Run configuration
      • Configuration used: Repository: TanStack/table/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 2c5e33a4-2152-4c14-aecc-ed7d1136ba0a

      📥 Commits

      Reviewing files that changed from the base of the PR and between f2ce8fa84e50049a158593b10103aa6a78db1dff and ff999f71e729bf87ab376e5f526761cb7ed6823e.


      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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 6aa0d74946b393f4f316085998bb6ec31c2ef593 and f2ce8fa84e50049a158593b10103aa6a78db1dff.


      📒 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 nameStatusExplanation
      Title check✅ PassedThe title clearly identifies the main change: moving App* context setup into the corresponding Svelte components.
      Description check✅ PassedThe description explains the bug, motivation, implementation, test coverage, and release impact. It includes all required template sections and completed checklist items.
      Linked Issues check✅ PassedIssue [#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✅ PassedThe 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✅ PassedDocstring 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.
    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit ff999f71e729bf87ab376e5f526761cb7ed6823e

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:sherif,t...✅ Succeeded3m 45sView ↗
      nx run-many --targets=build --exclude=examples/**✅ Succeeded29sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-12 15:00:21 UTC

    4. More templates

      @tanstack/alpine-table

      npm i https://pkg.pr.new/@tanstack/alpine-table@6618

      @tanstack/angular-table

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

      @tanstack/angular-table-devtools

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

      @tanstack/ember-table

      npm i https://pkg.pr.new/@tanstack/ember-table@6618

      @tanstack/lit-table

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

      @tanstack/match-sorter-utils

      npm i https://pkg.pr.new/@tanstack/match-sorter-utils@6618

      @tanstack/octane-table

      npm i https://pkg.pr.new/@tanstack/octane-table@6618

      @tanstack/preact-table

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

      @tanstack/preact-table-devtools

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

      @tanstack/react-table

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

      @tanstack/react-table-devtools

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

      @tanstack/solid-table

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

      @tanstack/solid-table-devtools

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

      @tanstack/svelte-table

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

      @tanstack/table-core

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

      @tanstack/table-devtools

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

      @tanstack/vue-table

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

      @tanstack/vue-table-devtools

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

      commit: ff999f7

    5. KevinVandy merged thisef60ec5

    6. KevinVandy closed this

    7. KevinVandy approved these changes

Sign in to join this conversation.