fix(preact): Unmount panels on Preact 11 and pass app context to plugins #551
main fromrefs/pull/551/head·merged by KevinVandy View on GitHubcreatePreactPanelreads the panel's element when the effect runs and checks that saved value in the cleanup. It used to readdevToolRef.currentin the cleanup. Preact 11 clears refs before effect cleanups run, so on Preact 11 the panel never calledunmount()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
preactdev dependency goes to^11.0.1inpreact-devtoolsand the Preact examples.devtools-utilsanddevtools-a11yget apreact^11.0.1dev 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
pxto numeric style values (that moved topreact/compat). The one numeric style inexamples/preact/basic(package-json-panel.tsx) now uses'Npx'strings, so it renders the same on Preact 10 and 11. @tanstack/preact-devtoolsrendered 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 passedclient. ThePortalnow forwards its context to that root throughgetChildContext. This affects Preact 10 too.createPortalwould be simpler, but it's only in core Preact 11, and importingpreact/compatpatches global options (such asonChange→onInput) in apps that don't use compat. Addstests/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
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.mdpackages/preact-devtools/src/devtools.tsxpackages/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.tsxThe 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.mdThe 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.mdThe 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
25c99No outstanding issue identified prevents merging after normal checks.
Pre-merge checks |
4 | 1-
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage 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… Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
-
Check name Status Explanation Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Title check The title clearly summarizes both primary changes: fixing Preact 11 panel unmounting and preserving app context for plugins. Description check The 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.
Comment `@coderabbitai help` to get the list of available commands.-
View your CI Pipeline Execution ↗ for commit 25c991d8622910c7c579caa71ee6a9bde8e2fa2d
Command Status Duration Result nx run-many --target=test:e2e --parallel=1 --pr...✅ Succeeded 1m 13s View ↗ nx run-many --targets=build --exclude=examples/...✅ Succeeded 3s View ↗ nx affected --targets=test:eslint,test:sherif,t...✅ Succeeded 27s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-11 16:58:23UTCMore templates
- @tanstack/devtools-example-preact-basic
- @tanstack/devtools-custom-devtools-preact
- @tanstack/devtools-example-angular-a11y-devtools
- @tanstack/devtools-example-angular-basic
- @tanstack/devtools-example-angular-panel
- ssr
- @tanstack/devtools-example-angular-with-devtools
- @tanstack/react-devtools-a11y-example
- @tanstack/devtools-example-react-basic
- start-repro
- @tanstack/devtools-custom-devtools
- tanstack-start-example-counter
- @tanstack/devtools-example-react-https
- start
- start-cloudflare
- start-nitro
- @tanstack/devtools-example-react-time-travel
- @tanstack/solid-devtools-a11y-example
- @tanstack/devtools-example-solid-basic
- @tanstack/devtools-example-devtools-ui
- @tanstack/devtools-example-solid-start
- @tanstack/query-example-vue-basic
@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@551commit:
25c991dReview the following changes in direct dependencies. Learn more about Socket for GitHub.
Diff Package Supply Chain
SecurityVulnerability Quality Maintenance License preact@10.29.1 ⏵ 11.0.1 +1
+1
KevinVandy changed the title
KevinVandy merged thise122872
KevinVandy closed this
Sign in to join this conversation.
🦋 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
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