feat: Add reorderOnDrag prop to delay sorting until the item is dropped#577
Closed
MatiPl01 wants to merge 1 commit into
Closed
feat: Add reorderOnDrag prop to delay sorting until the item is dropped#577MatiPl01 wants to merge 1 commit into
MatiPl01 wants to merge 1 commit into
Conversation
When reorderOnDrag is false, items don't reorder during the drag. The prospective order is computed while dragging and committed in handleDragEnd before onDragEnd/onActiveItemDropped fire, so the drag-end callbacks report the final order instead of the pre-drop one.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Owner
Author
|
Closing this. After building and testing it, delaying the reorder until drop means there's no preview of where the active item will land while dragging, which makes the interaction feel worse than the default live reordering. The default behavior already covers these cases well, so this isn't a good fit to add and isn't needed. |
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.
Description
Adds a
reorderOnDragprop (defaulttrue). WithreorderOnDrag={false}items don't reorder while dragging; the new order is applied only when the active item is dropped. Builds on #525 and fixes the drag-end callback ordering.The prospective order is now computed during the drag and committed in
handleDragEndbeforeonDragEnd/onActiveItemDroppedfire, so those callbacks (and the griddataparam) report the final order. In #525 the reorder was applied by a deferred reaction that ran afteronDragEnd, so a controlled list updating fromparams.dataon drop persisted the pre-drop order.Changes showcase
reorderOnDrag={false}with controlled data (onDragEnd={p => setData(p.data)}), dragging Item 1 across the grid:Before, the dropped item lands in the wrong place because
onDragEndreports the pre-reorder order (from 0 to 0). After, it lands exactly where dropped (from 0 to 7) and the controlled order sticks.Key change
Verified on iOS (Fabric) for
Sortable.GridandSortable.Flex, withreorderOnDragbothtrue(items reorder during the drag, unchanged) andfalse. Docs for the prop, a test, and the drop indicator preview in this mode are still TODO.