Skip to content

fix(hierarchical-document-list): update react-sortable-tree to 7.1.0 - #2253

Open
pedrobonamin wants to merge 4 commits into
mainfrom
cursor/hierarchical-document-list-sortable-tree-7-315b
Open

pedrobonamin wants to merge 4 commits into
mainfrom
cursor/hierarchical-document-list-sortable-tree-7-315b

Conversation

@pedrobonamin

@pedrobonamin pedrobonamin commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Third of three stacked PRs, on top of #2251:

  1. fix(hierarchical-document-list): restore nesting and same-level moves in the tree #2246: pin @nosferatu500/react-sortable-tree to 5.0.0 and fix same-level moves.
  2. test(hierarchical-document-list): cover drag-and-drop moves with Playwright #2251: a Playwright suite for the tree's drag-and-drop.
  3. This PR: upgrade to 7.1.0.

Summary

Changes needed to upgrade from 5.0.0 to 7.1.0, following the library's changelog:

  • Drag-and-drop packages: 7.0 swapped the react-dnd peer for the maintained forks. react-dnd / react-dnd-html5-backend 16 become @nosferatu500/react-dnd / @nosferatu500/react-dnd-html5-backend ^19.2, including the DndProvider and HTML5Backend imports in TreeEditor.
  • Stylesheet: 6.0 stopped injecting styles at runtime, so the plugin imports @nosferatu500/react-sortable-tree/style.css (with a css.d.ts module declaration, like sanity-plugin-latex-input). Screenshots of the e2e tree on 5.0.0 and 7.1.0 look the same, both at rest and mid-drag.
  • slideRegionSize: removed in 6.0, so it's dropped from getCommonTreeProps.
  • Types: 7.1 made TreeItem generic. LocalTreeItem is now TreeItem<EnhancedTreeItem>, and getCommonTreeProps, getTreeHeight and getNodeKey carry that type, so SortableTree infers it.

The lockfile was resolved through a local registry proxy that serves the locked 6.21.0-next.1 as the Studio packages' next dist-tag, as described in AGENTS.md. The unrelated peer-suffix toggle (@vitejs/devtools / oxc-transform-react on debug-preview-url-secret-plugin) and @opentelemetry deprecation-note changes were reverted. What remains is the library, the @nosferatu500 drag-and-drop packages, virtua 0.50.6, and the removal of react-dnd 16 and what only it used (dnd-core, @react-dnd/*, redux 4). pnpm install --frozen-lockfile passes, including the supply-chain checks, and the lockfile has no localhost or tarball: entries.

Upward drags skipped in Playwright's Firefox

With 7.1.0, Playwright's Firefox often drops an upward drag on the row that was under the pointer before the rows shifted. The library's onMoveNode then reports a position one row short, or doesn't fire. Repeating the same upward drag 8 times gave:

  • 7.1.0, Playwright's Firefox: about half the drops wrong.
  • 7.1.0, Chromium: 8/8 correct.
  • 5.0.0, Playwright's Firefox: 8/8 correct.

The same moves were checked by hand in a real Firefox and work correctly, so this is an artifact of Playwright's Firefox drag emulation. The two upward-drag tests ("moves an item up within the same level" and "moves an item together with its nested children") are skipped in Firefox only, with a comment explaining why. They still run in Chromium. Moving down, nesting and un-nesting run in both browsers.

Testing

  • CI e2e: 54 passed, 2 skipped (the two upward drags in Firefox).
  • pnpm build (54/54), pnpm lint, pnpm knip and the plugin's Vitest project pass.
Open in Web Open in Cursor 

Note

Medium Risk
Changes core tree drag-and-drop behavior and dependencies; upward reordering is flaky in Firefox per author testing, while Chromium looks fine.

Reviewed by Cursor Bugbot for commit ed89a41. Configure here.

@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
plugins-studio Ready Ready Preview Nov 2, 2026 7:44am UTC
1 Skipped Deployment
Project Deployment Actions Updated
plugins-e2e-test-studio Ignored Ignored Nov 2, 2026 7:44am UTC

Request Review

@pedrobonamin pedrobonamin added the ✨ ai PR authored by an AI agent (🤖 bot is for CI automation/Renovate) label Oct 23, 2026 — with Cursor
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

✅ E2E Tests

🟢 54 passed • (⚪ 2 skipped) • view full report • view run

Studio: https://plugins-e2e-test-studio-qenqi3f7g.sanity.dev

Datasets: pr-2253-chromium-41408072176, pr-2253-firefox-41408072176

@socket-security

socket-security Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

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

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​nosferatu500/​react-dnd-html5-backend@​19.2.0771008188100
Addednpm/​@​nosferatu500/​react-dnd@​19.2.0781008288100
Updatednpm/​@​nosferatu500/​react-sortable-tree@​5.0.0 ⏵ 7.1.097 +310010093 +8100

View full report

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 38.95% 7911 / 20306
🔵 Statements 38.91% 8509 / 21865
🔵 Functions 34.5% 2161 / 6262
🔵 Branches 31.14% 4608 / 14796
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
plugins/@sanity/hierarchical-document-list/src/index.ts 100% 100% 100% 100%
plugins/@sanity/hierarchical-document-list/src/components/TreeEditor.tsx 6.66% 0% 0% 7.14% 34-183, 190
plugins/@sanity/hierarchical-document-list/src/utils/getCommonTreeProps.tsx 0% 100% 0% 0% 16-19
plugins/@sanity/hierarchical-document-list/src/utils/getTreeHeight.ts 0% 100% 0% 0% 7-10
plugins/@sanity/hierarchical-document-list/src/utils/treePatches.ts 0% 0% 0% 0% 36-133
Generated in workflow #11491 for commit 0b221fe by the Vitest Coverage Report Action

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ed89a41. Configure here.

@pedrobonamin
pedrobonamin added this pull request to stack #2252 October 23, 2026 09:26
@changeset-bot

changeset-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0b221fe

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

This PR includes changesets to release 1 package
Name Type
@sanity/hierarchical-document-list Patch

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

@pedrobonamin
pedrobonamin marked this pull request as ready for review October 23, 2026 09:43
@pedrobonamin
pedrobonamin requested a review from a team as a code owner October 23, 2026 09:43
@pedrobonamin
pedrobonamin requested review from juice49 and removed request for a team October 23, 2026 09:43
pedrobonamin added a commit that referenced this pull request Oct 23, 2026
… 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>&nbsp;<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>&nbsp;</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>
@pedrobonamin
pedrobonamin force-pushed the cursor/hierarchical-document-list-sortable-tree-7-315b branch from 2aa8385 to a2626d9 Compare October 23, 2026 10:23
@cursor
cursor Bot force-pushed the cursor/hierarchical-document-list-sortable-tree-7-315b branch from a2626d9 to 2f364ef Compare October 26, 2026 15:36
cursoragent and others added 4 commits November 2, 2026 07:38
…wright

Co-authored-by: Pedro Bonamin <pedrobonamin@users.noreply.github.com>
Co-authored-by: Pedro Bonamin <pedrobonamin@users.noreply.github.com>
…irefox

Co-authored-by: Pedro Bonamin <pedrobonamin@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/hierarchical-document-list-sortable-tree-7-315b branch from 2f364ef to 0b221fe Compare November 2, 2026 07:42
Base automatically changed from cursor/hierarchical-document-list-e2e-315b to main November 2, 2026 15:56
pedrobonamin added a commit that referenced this pull request Nov 2, 2026
…wright (#2251)

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
Second of three stacked PRs, on top of #2246:

1. #2246: pin `@nosferatu500/react-sortable-tree` to 5.0.0 and fix
same-level moves.
2. **This PR:** a Playwright suite for the tree's drag-and-drop.
3. #2253: upgrade to 7.1.0, checked by this suite.

## Summary

This wires `@sanity/hierarchical-document-list` into `dev/e2e-studio`,
adding a `hierarchyBook` schema, the plugin's `hierarchy.tree` type, and
a **Hierarchy** structure item for the `hierarchy-e2e-tree` document in
both workspaces. It also adds a spec that drags rows by their handle
with real mouse movement.

| Test | Seeded tree | Drag | Expected |
| --- | --- | --- | --- |
| moves an item up within the same level | `alpha, bravo, charlie` |
charlie over alpha | `charlie, alpha, bravo` |
| moves an item down within the same level | `alpha, bravo, charlie` |
alpha over charlie | `bravo, charlie, alpha` |
| nests an item under the item above it | `alpha, bravo, charlie` |
bravo 60px right | `alpha[bravo], charlie` |
| moves a nested item out to the root | `alpha[bravo], charlie` | bravo
30px left | `alpha, bravo, charlie` |
| moves an item together with its nested children | `alpha,
bravo[delta], charlie` | bravo over alpha | `bravo[delta], alpha,
charlie` |



[video.webm](https://github.com/user-attachments/assets/dc2e4819-dca0-441f-b676-6e977e950db6)


[video.webm](https://github.com/user-attachments/assets/351b3554-5cf7-4a00-97e3-b796dec34043)


[video.webm](https://github.com/user-attachments/assets/da746195-1d57-40a9-a468-1ad8487639c5)


[video.webm](https://github.com/user-attachments/assets/fdd143c7-c642-4fd1-8b24-3014f7d9221e)


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 plus `parent`) 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:

- This spec: 5/5 pass in Chromium and 5/5 in Firefox.
- The whole e2e suite: 56 passed, 4.3 minutes.
- Against `main`'s code (react-sortable-tree 5.1.0 and the old
`canDrop`), all five scenarios fail in Chromium. For example, the
move-up test expects `charlie, alpha, bravo` and gets `alpha, bravo,
charlie`.

`pnpm lint`, `pnpm knip`, the e2e studio build and `tsc` for `e2e/`
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>&nbsp;<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>&nbsp;</div>

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Changes are limited to the e2e studio, Playwright tests, and
documentation; no production plugin runtime behavior is modified in this
PR.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
326b58a. 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>

This branch was successfully deployed

1 active deployment
Preview – plugins-studio — 0b221fe5 Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ ai PR authored by an AI agent (🤖 bot is for CI automation/Renovate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants