Skip to content

sideboard: a move takes only the link that was dragged - #117

Open
pvh wants to merge 1 commit into
mainfrom
sideboard-drop-duplicates
Open

pvh wants to merge 1 commit into
mainfrom
sideboard-drop-duplicates

Conversation

@pvh

@pvh pvh commented Dec 2, 2026

Copy link
Copy Markdown
Member

Dropping a document into a folder could create duplicate entries.

Cause: a move looked up the dragged document by url across the whole tree, not at the dragged row. A document linked from two folders lost both links and landed twice in the target, and the other folder silently lost its link.

Fix:

  • The drag payload now carries the row's parent folder and index (parentUrl, index). A move takes exactly that link. If the tree changed mid-drag and the index no longer holds the doc, it takes the doc's link in the same folder, then its first link anywhere.
  • A move or copy no longer adds a second link to a document the target folder already holds. Drops from another view already behaved this way. Moving into such a folder just removes the dragged link. Copying into one says "already in this folder" and changes nothing.

Side effect: reordering a doc within a folder that already held two links to it now leaves one.

Testing

  • New cases in dnd/drop.test.ts: dragging either of two links to the same doc; a stale index; moving into a folder that already links to the doc; copying into one. All four fail against the old operations.ts.
  • vitest, tsc --noEmit, pnpm build pass in sideboard/.
  • Not yet tried in a browser.

🤖 Generated with Claude Code

A move looked up the dragged doc by url across the whole tree, so a doc
linked from two folders lost both links and landed twice in the target.
The drag now carries the row's folder and index, and the move takes that
one link (falling back to the doc's link in the same folder, then its
first link anywhere, if the tree changed mid-drag). A move or copy also
no longer adds a second link to a doc the target folder already holds,
as a drop from another view already didn't.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@patchcrow

patchcrow commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Patchwork glance ready

https://patchwork-preview-117--patchwork-base.netlify.app

Patchwork from inkandswitch/patchwork.inkandswitch.com, packages from this PR at f15f064.

build-info.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants