Skip to content
Source
Sign inSign up
TanStack/devtools

fix(preact): Unmount panels on Preact 11 and pass app context to plugins #551

MergedKevinVandymerged 4 commits intomain fromrefs/pull/551/headmerged by KevinVandy View on GitHub

KevinVandycommented
  • createPreactPanel reads the panel's element when the effect runs and checks that saved value in the cleanup. It used to read devToolRef.current in the cleanup. Preact 11 clears refs before effect cleanups run, so on Preact 11 the panel never called unmount() on the devtools core.
  • Adds src/preact/panel.test.ts. It fails without the fix on Preact 11, and passes with it on Preact 10 and 11.
  • Patch changeset for @tanstack/devtools-utils.
  • The preact dev dependency goes to ^11.0.1 in preact-devtools and the Preact examples. devtools-utils and devtools-a11y get a preact ^11.0.1 dev dependency, so their tests run on Preact 11 rather than the auto-installed Preact 10 peer. The peer ranges are unchanged (>=10.0.0).
  • Preact 11 no longer adds px to numeric style values (that moved to preact/compat). The one numeric style in examples/preact/basic (package-json-panel.tsx) now uses 'Npx' strings, so it renders the same on Preact 10 and 11.
  • @tanstack/preact-devtools rendered plugins, titles and custom triggers into a separate Preact root, so they lost the app's context. For example, <PreactQueryDevtoolsPanel /> threw "No QueryClient set" inside <QueryClientProvider> unless it was passed client. The Portal now forwards its context to that root through getChildContext. This affects Preact 10 too. createPortal would be simpler, but it's only in core Preact 11, and importing preact/compat patches global options (such as onChange → onInput) in apps that don't use compat. Adds tests/devtools.test.tsx, which fails without the fix and passes with it on Preact 10 and 11. Patch changeset for @tanstack/preact-devtools.

Notes

createReactPanel uses the same ref check in its cleanup. React also clears refs before passive effect cleanups, so it likely has the same leak. This PR doesn't change it, because the React panel has other in-progress changes.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Plugins, titles, and custom triggers now inherit the rendering app’s Preact context.
  • Bug Fixes
    • Devtools panels now unmount reliably with Preact 11, including during effect cleanup.
  • Compatibility
    • Updated the Preact examples and development setup to use Preact 11.
  • Style
    • Adjusted package panel styling to keep dimensions consistent with pixel-based values.
    1. changeset-bot[bot](GitHub profile, opens in a new tab)commented

      🦋 Changeset detected

      Latest commit: 25c991d8622910c7c579caa71ee6a9bde8e2fa2d

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

      This PR includes changesets to release 2 packages
      NameType
      @tanstack/devtools-utilsPatch
      @tanstack/preact-devtoolsPatch

      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 →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Repository: TanStack/devtools/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 6891710e-00cd-40e1-b783-f1241f752c38


      📥 Commits

      Reviewing files that changed from the base of the PR and between f1c68aab87dee28dfa1195fcf5ddc7fa317df1fd and 25c991d8622910c7c579caa71ee6a9bde8e2fa2d.



      📒 Files selected for processing (3)
      • .changeset/preact-devtools-plugin-context.md
      • packages/preact-devtools/src/devtools.tsx
      • packages/preact-devtools/tests/devtools.test.tsx


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




      📝 Walkthrough
      📝 Walkthrough

      Walkthrough

      The changes update Preact dependencies to 11.0.1, adjust CSS values in the basic example, and change panel cleanup to use the element captured before effect cleanup. The Preact devtools portal also provides app context to children rendered in a separate root.

      Changes

      Preact compatibility and devtools behavior

      Layer / File(s)Summary
      Preact dependencies and example styles
      e2e/apps/preact/package.json, examples/preact/basic/package.json, examples/preact/custom-devtools/package.json, packages/devtools-a11y/package.json, packages/devtools-utils/package.json, packages/preact-devtools/package.json, examples/preact/basic/src/package-json-panel.tsx
      The e2e app and examples use Preact 11.0.1. The a11y and devtools-utils packages add Preact 11.0.1 as a development dependency. The basic example changes specified numeric CSS values to pixel strings.
      Panel cleanup lifecycle
      packages/devtools-utils/src/preact/panel.tsx, packages/devtools-utils/src/preact/panel.test.ts, .changeset/devtools-utils-preact-11-unmount.md
      The panel cleanup checks the element captured before mounting instead of rereading the ref. A test verifies that mounting and then removing the panel calls the core devtools mount and unmount methods once. A changeset describes the Preact 11 unmount issue.
      Context propagation through the portal
      packages/preact-devtools/src/devtools.tsx, packages/preact-devtools/tests/devtools.test.tsx, .changeset/preact-devtools-plugin-context.md
      The portal provides app context to children rendered in a separate root. Tests check initial and updated context values, then verify that unmounting clears the container. A changeset describes the context behavior for plugins, titles, and custom triggers.

      Priority: ⬇️ Low

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

      Change: Bug fix · Severity of issue fixed: Low

      Sequence Diagram(s)

      sequenceDiagram
        participant App
        participant Portal
        participant SeparateRoot
        App->>Portal: Pass app context and children
        Portal->>SeparateRoot: Render children through ContextProvider
        SeparateRoot-->>App: Display context value


      Merge Risk: ⚪ Minimal · up to 25c99

      No outstanding issue identified prevents merging after normal checks.

      Pre-merge checks | Passed 4 | Failed 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. (1 skipped: 1…Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Title checkPassedThe title clearly summarizes both primary changes: fixing Preact 11 panel unmounting and preserving app context for plugins.
      Description checkPassedThe description clearly explains the fixes, motivation, tests, dependency updates, changesets, compatibility, and known React follow-up. It does not use the required template headings or include the c…

      Full details: Docstring Coverage

      Explanation

      Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 5 files. (1 skipped: 1 unsupported.)


      • Fix all pre-merge checks with AI
      ✨ Finishing Touches 💡 1
      📝 Generate docstrings 💡
      • Commit to this branch
      • Create a new PR






      🧪 Generate unit tests (beta)
      • Commit to this branch
      • 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

      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 25c991d8622910c7c579caa71ee6a9bde8e2fa2d

      CommandStatusDurationResult
      nx run-many --target=test:e2e --parallel=1 --pr...✅ Succeeded1m 13sView ↗
      nx run-many --targets=build --exclude=examples/...✅ Succeeded3sView ↗
      nx affected --targets=test:eslint,test:sherif,t...✅ Succeeded27sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-11 16:58:23 UTC

    4. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented
      More templates

      @tanstack/angular-devtools

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

      @tanstack/devtools

      npm i https://pkg.pr.new/@tanstack/devtools@551

      @tanstack/devtools-a11y

      npm i https://pkg.pr.new/@tanstack/devtools-a11y@551

      @tanstack/devtools-bundler-core

      npm i https://pkg.pr.new/@tanstack/devtools-bundler-core@551

      @tanstack/devtools-client

      npm i https://pkg.pr.new/@tanstack/devtools-client@551

      @tanstack/devtools-rspack

      npm i https://pkg.pr.new/@tanstack/devtools-rspack@551

      @tanstack/devtools-ui

      npm i https://pkg.pr.new/@tanstack/devtools-ui@551

      @tanstack/devtools-utils

      npm i https://pkg.pr.new/@tanstack/devtools-utils@551

      @tanstack/devtools-vite

      npm i https://pkg.pr.new/@tanstack/devtools-vite@551

      @tanstack/devtools-webmcp

      npm i https://pkg.pr.new/@tanstack/devtools-webmcp@551

      @tanstack/devtools-event-bus

      npm i https://pkg.pr.new/@tanstack/devtools-event-bus@551

      @tanstack/devtools-event-client

      npm i https://pkg.pr.new/@tanstack/devtools-event-client@551

      @tanstack/preact-devtools

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

      @tanstack/react-devtools

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

      @tanstack/solid-devtools

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

      @tanstack/svelte-devtools

      npm i https://pkg.pr.new/@tanstack/svelte-devtools@551

      @tanstack/vue-devtools

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

      commit: 25c991d

    5. socket-security[bot](GitHub profile, opens in a new tab)commented

      Review the following changes in direct dependencies. Learn more about Socket for GitHub.

      Diff Package Supply Chain
      Security
      Vulnerability Quality Maintenance License
      Updatedpreact@​10.29.1 ⏵ 11.0.1100 +1100100 +196100

      View full report

    6. KevinVandy changed the title

    7. KevinVandy merged thise122872

    8. KevinVandy closed this

Sign in to join this conversation.