Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
🦋 Changeset detectedLatest commit: baa8bcd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ E2E Tests🟢 46 passed • view full report • view run Studio: https://plugins-e2e-test-studio-3ue08fyx9.sanity.dev Datasets: |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
Review: approveVerified
Notes (none blocking)
VerdictApprove. Small, correct, and the test guards the regression. |
cursor
Bot
force-pushed
the
cody/hierarchical-document-list-keep-tree-while-hidden-8079
branch
from
October 22, 2026 16:29
310bd1c to
cf74bf4
Compare
cursor
Bot
force-pushed
the
cody/hierarchical-document-list-keep-tree-while-hidden-8079
branch
from
October 23, 2026 13:30
cf74bf4 to
4b18c43
Compare
cursor
Bot
force-pushed
the
cody/hierarchical-document-list-keep-tree-while-hidden-8079
branch
from
October 26, 2026 16:07
4b18c43 to
f6e6627
Compare
…ity boundary hides it
With `beta.reactActivityMode` the Studio keeps recently used tools mounted behind
`<Activity>`, which detaches refs while a tool is hidden and attaches them again on
reveal. `TreeEditor` kept the element its `DndProvider` needs in state through
`ref={setContext}` and rendered the tree only while that state was set, so the detach
unmounted the whole tree (the drag-and-drop provider, every row and every document in
the "Add more items" list) in the background and the reveal rebuilt it.
The box is always rendered, so the only `null` React ever passes is that detach; the
ref callback now ignores it and the element lives as long as the editor.
Co-authored-by: Cody Olsen <stipsan@users.noreply.github.com>
cursor
Bot
force-pushed
the
cody/hierarchical-document-list-keep-tree-while-hidden-8079
branch
from
October 27, 2026 12:03
f6e6627 to
baa8bcd
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With
beta.reactActivityMode, hiding the Structure tool with a hierarchy open unmounted the whole tree in the background and the reveal rebuilt it. The Studio keeps recently used tools mounted behind<Activity>, which detaches refs while a tool is hidden (callback refs are called withnull) and attaches them again on reveal.TreeEditorkept the element itsDndProviderneeds in state throughref={setContext}and only rendered the tree while that state was set, so the detach dropped the drag-and-drop provider, every row and every document in the "Add more items" list, and the reveal mounted them all again (the same pattern as sanity-io/sanity#15309'suseElementState).The box is always rendered, so the only
nullReact ever passes is that detach; the ref callback now ignores it and the element lives as long as the editor.What to review
TreeEditor.tsx: the ref callback on theBox.package.json/pnpm-lock.yaml:@testing-library/reactandjsdomascatalog:devDependencies for the test (the lockfile change is the two importer entries).Affects
@sanity/hierarchical-document-list.Testing
TreeEditor.test.tsx(jsdom, Studio hooks mocked): the box's child, the tree, is the same element while an<Activity>boundary hides the editor and after it shows it again. Onmainthe box is empty while hidden.pnpm --filter @sanity/hierarchical-document-list exec vitest run,pnpm build,pnpm lint,pnpm knip,pnpm formatare clean.dev/test-studio(Structure → Document list builders → Main table of contents,reactActivityModeon) with a headed Playwright harness that switches to Vision, waits 7s, switches back and records React commits and mounted components until the page is quiet for 30 frames. Before: 8731 components mounted on reveal, starting withDndProviderand 38DocumentInNodes (3302 in one commit). After: 5005, none of them the tree itself. What remains is not this plugin's:@nosferatu500/react-sortable-treeremounts its rows on every re-render (itsmergedPropsmemo is keyed onprops), and the reveal re-renders it three times (the edit state and the preview store reconnecting, theuseAllItemsrefetch), plus the@sanity/uitooltip contents of the re-resolved document previews. The tool area paints in 1 frame before and after; the background unmount was invisible, only wasteful, and it reset the tree's internal state (open menus, the list's scroll position) on every switch.Notes for release
Fixes the hierarchy tree being torn down and rebuilt on every switch away from and back to the Structure tool in a Studio with
beta.reactActivityModeenabled.