… in the tree (#2246)
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
First of three stacked PRs:
1. **This PR:** pin `@nosferatu500/react-sortable-tree` to 5.0.0 and fix
same-level moves.
2. #2251: a Playwright suite covering reordering, nesting, un-nesting
and moving a whole subtree.
3. #2253: upgrade to 7.1.0, checked by that suite.
## Summary
https://github.com/user-attachments/assets/d5bee535-58cc-4fd9-a93d-feadfe6cc0a4
Two separate bugs broke drag-and-drop in the tree.
**Nesting saved the item at the top level** (commit 1). Renovate moved
the plugin from `^5.0.0` to `^5.1.0` in #1881, and 5.1.0 has a
regression in `insertNode`. Its recursive helper spreads `...params`,
which carries `isPseudoRoot: true` into every nested level, so
`onMoveNode` always receives `nextParentNode: null`. 5.0.0 passes
explicit arguments, and 7.1.0 fixes it with `isPseudoRoot: false`. This
pins the dependency to exactly `5.0.0`. The lockfile change is
hand-edited to just the library and its `virtua` dependency (0.50.6 →
0.48.8, only used by this library), because a regular install
re-resolves the Studio `next` overrides. `pnpm install
--frozen-lockfile` accepts it, including the supply-chain checks.
**Moving an item up or down within its level snapped it back** (commit
2). This bug isn't version-specific. Since 9113861, `getNodeKey`
returns the row's `_key`, so tree paths are made of keys rather than
positions. `canDrop` rejected a drop when the new path started with the
old one, which is always true for a move within the same level
(`['charlie']` before and after). It now only rejects drops whose new
parents include the dragged row itself.
This supersedes #2245, which worked around the missing parent but left
same-level moves broken.
## Testing
#2251 adds a Playwright suite covering moving an item up and down,
nesting, un-nesting and moving an item with its children. It passes on
this branch in Chromium and Firefox. With `main`'s code (5.1.0 and the
old `canDrop`), all five scenarios fail in Chromium. `pnpm build`, `pnpm
lint`, `pnpm knip` and the plugin's Vitest project pass.
<!-- CURSOR_AGENT_PR_BODY_END -->
<div><a
href="https://cursor.com/agents/bc-010edcd6-3b41-43cc-a8a6-2b950822315b?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a
href="https://cursor.com/background-agent?bcId=bc-010edcd6-3b41-43cc-a8a6-2b950822315b&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div>
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Dependency pin and lockfile-only transitive changes; restores prior
nesting behavior without touching plugin application logic.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ae56fa1. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Pedro Bonamin <pedrobonamin@users.noreply.github.com>
Second of three stacked PRs, on top of #2246:
@nosferatu500/react-sortable-treeto 5.0.0 and fix same-level moves.Summary
This wires
@sanity/hierarchical-document-listintodev/e2e-studio, adding ahierarchyBookschema, the plugin'shierarchy.treetype, and a Hierarchy structure item for thehierarchy-e2e-treedocument in both workspaces. It also adds a spec that drags rows by their handle with real mouse movement.alpha, bravo, charliecharlie, alpha, bravoalpha, bravo, charliebravo, charlie, alphaalpha, bravo, charliealpha[bravo], charliealpha[bravo], charliealpha, bravo, charliealpha, bravo[delta], charliebravo[delta], alpha, charlievideo.webm
video.webm
video.webm
video.webm
Each test seeds the books and the tree through the Content Lake API and deletes them in
finally. Every test checks both the saved document (sibling order plusparent) and the rendered rows (order plus indentation). The tests share one tree document, so the describe block runs serially.The structure tool now has a custom structure: all document type lists, then the hierarchy item. The other suites navigate with intents, so they aren't affected.
Testing
Run locally against ephemeral datasets:
main's code (react-sortable-tree 5.1.0 and the oldcanDrop), all five scenarios fail in Chromium. For example, the move-up test expectscharlie, alpha, bravoand getsalpha, bravo, charlie.pnpm lint,pnpm knip, the e2e studio build andtscfore2e/pass.Note
Low Risk
Changes are limited to the e2e studio, Playwright tests, and documentation; no production plugin runtime behavior is modified in this PR.
Reviewed by Cursor Bugbot for commit 326b58a. Configure here.