fix(checklist): respect drop position when reordering subitems#518
Open
reniko wants to merge 1 commit into
Open
fix(checklist): respect drop position when reordering subitems#518reniko wants to merge 1 commit into
reniko wants to merge 1 commit into
Conversation
Subitem drag-and-drop always inserted the dragged item before the drop target instead of at the indicated position, so it landed at the top of the parent's children. The before/after check in handleDragEnd matched the drop-zone id prefix "drop-after::", but subitem drop indicators use the prefix "drop-after-child::". The check never matched for subitems, so position always fell back to "before". Top-level reorder was unaffected because its indicators do use "drop-after::". Match the prefix "drop-after" so both top-level and subitem indicators resolve correctly, consistent with the isDropIndicator check that already uses that prefix. Co-Authored-By: Claude Opus 4.7 <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
Dragging a subitem and dropping it between two siblings always inserted
it at the top of the parent's children list, ignoring the drop position.
Top-level reordering was unaffected.
Steps to reproduce
Awith subitemsA1,A2,A3.A3and drop it betweenA1andA2.A1, A3, A2. Actual order:A3, A1, A2.Reproduces on
developin Firefox, Edge and Brave.Root cause
handleDragEndinapp/_hooks/useChecklist.tsxdecides whether to dropbefore or after the target by matching the drop-zone id prefix
"drop-after::". Top-level drop indicators use that prefix, but subitemdrop indicators use
"drop-after-child::"(seeNestedChecklistItem.tsx)."drop-after-child::…".startsWith("drop-after::")isfalse, so thecheck never matched for subitems and
positionalways fell back to"before"— inserting the dragged item before the target instead ofafter it.
The same check is used both for the optimistic local update and for the
positionvalue sent to thereorderItemsserver action, so the wrongresult was consistent and persisted to disk.
Fix
Match the prefix
"drop-after"(without the trailing::) at both callsites, so it matches
drop-after::anddrop-after-child::alike. Thismirrors the
isDropIndicatorcheck a few lines above, which already usesthe
"drop-after"/"drop-before"prefixes.drop-before/drop-before-childindicators still correctly fall through to"before".Two-line change, no other files. The server action was already correct —
it just consumes the
positionit receives.Tests done
A3dropped betweenA1andA2→A1, A3, A2