feat(data-lit-todo): drag-reorder via useDragGenerator + dragTodo action - #199
Merged
Merged
Conversation
…dragTodo action Replaces the todo row's useDragTransaction with the useDragGenerator hook: it hands the raw DragState stream to a new dragTodo action, which maps each frame to the dragTodo transaction's args and drives the transaction with the mapped async generator. This is the textbook useDragGenerator → action → multi-frame transaction pattern. The action maps drag→args (row height passed in as data, never imported from ui/); a cancelled gesture yields dragPosition: null to abandon the drag with no reorder. Covered by a dragTodo action unit test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
Adds the missing textbook example of the
useDragGenerator+ async-generator-to-transaction pattern to thedata-lit-todosample. Previously the sample had no correct demonstration of driving a multi-frame transaction fromuseDragGenerator.The flow is now:
todo-row-elementcallsuseDragGenerator, which hands the rawDragStatestream to…dragTodoaction, which maps each yielded drag frame to thedragTodotransaction's args and drives the transaction with that mapped async generator, so…dragTodotransaction commits every frame (live offsets + final drop) as one coalesced, undoable step.Details
action-database/actions/drag-todo.ts— mapsmove→live offset,end→final drop (finalIndex),cancel→{ dragPosition: null }(abandon with no reorder). Row height is passed in as a plain arg, never imported, soservices/keeps its strict independence fromui/.drag-todotransaction input widened todragPosition: number | nullso a cancelled gesture resets cleanly.todo-row-elementswitched fromuseDragTransactiontouseDragGenerator; arg-shaping now lives in the action per the container-element rule (no shape-building in a callback).reorder-todoaction doc updated to reflect the new drag path.Test plan
drag-todo.test.tsunit test covers both the reorder (move→end) and the cancel (move→cancel, no reorder) paths.data-lit-todosuite passes (109 tests, incl. conformance).typecheck(cleared tsbuildinfo) andlintpass; bundledbuildsucceeds (no TLA deadlock).🤖 Generated with Claude Code