Restore archived widgets by dragging them into any board slot#79
Merged
Conversation
Archiving and restoring both used the same drop strip pinned to the bottom of the viewport, so restoring meant dragging a card down to the very spot used to archive it — the reverse action shared the same target and read as unintuitive. Make restore the spatial mirror of archive: the restore drop zone now pins to the top over the active board, so an archived card is dragged back up onto the board to bring it back, and can be dropped anywhere across the zone. Both zones share one medium size and differ only in position. The DropZone component takes a `placement` and the restore variant only overrides its vertical anchor; the two DnD contexts and the archive/restore reducers are unchanged. Update the Playwright restore test to drag up and assert the target sits above the card being restored.
One shared drag context (BoardDnd) now spans the active board and the archived list, so an archived card can be dragged onto any board card and take its slot, with the board outlined and the hovered card ringed as live feedback. An empty board doubles as the drop target. Archiving keeps the simple bottom drop zone; the mirrored restore zone is gone.
While an archived card hovers over the board, BoardDnd swaps in a preview list where the restore already happened: the card joins the board grid as a dimmed placeholder and the other cards part to make room, exactly like a native reorder. Dropping commits the previewed slot; dragging back to the archive or cancelling discards it. The lists now render through a render prop so they follow the preview.
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.
What
Dragging a card out of the archive now works exactly like a normal board drag: carry it up onto the board and the board parts to make room — the card joins the grid as a dimmed placeholder in the slot it will take, tracking the cursor just like a native reorder. Drop to restore it there. The previous fixed "restore zone" overlay is gone. Archiving is unchanged — drag a board card down to the simple drop zone at the bottom.
How
BoardDndcomponent — a singleDndContextshared by the active board and the archived list, so a card can travel between the two sortable grids mid-drag. It owns the sensors, the archive drop zone, the drag overlay, and routes drops: same list → reorder; archived → board → restore into the previewed slot; board card → archived card → archive.onDragOver,BoardDndbuilds a preview widget list where the restore already happened, and the page renders through a render prop that follows it. Once the card is a member of the board''s sortable context, dnd-kit''s own sort transforms take over, so within-board movement is pixel-identical to a normal reorder. Dragging back over the archive or cancelling discards the preview; dropping commits it through the samerestoreWidgetstorage path.BoardListslimmed down — no longer owns a drag context; it reads the shared one viauseDndContext. A newrestoreTargetflag marks the active board: it outlines while an archived card approaches, and an empty board doubles as a drop target ("Drop it here to restore") so restore-by-drag still works when everything is archived.restoreWidget(widgets, id, beforeId?)— takes an optional board card to insert in front of; without one it falls back to the end of the board as before.Tests