Respect put: false on the revert-to-origin path#2465
Open
nandastone wants to merge 1 commit intoSortableJS:masterfrom
Open
Respect put: false on the revert-to-origin path#2465nandastone wants to merge 1 commit intoSortableJS:masterfrom
nandastone wants to merge 1 commit intoSortableJS:masterfrom
Conversation
When a dragged item has left its source sortable and the cursor hovers back over it, _onDragOver enters the "revert" branch (line 1152) to move dragEl back to its origin. This branch checks `canSort` but never checks `group.checkPut`, so `put: false` is silently ignored for the owner sortable. The non-owner branch (line 1154-1158) already gates on `checkPut`. This change makes the owner branch symmetric: revert only proceeds if `checkPut` also allows it. Lists that declare `put: false` will no longer have their own items forcibly reinserted during a cross-list drag. Backward compatibility: only affects sortables that explicitly set `put: false`. The default (`put: true` or unset) is unchanged, because `checkPut` returns true.
Author
|
Unsure if I should add a new Testcafe fixture for this. Existing tests will catch any regressions. Please advise. |
nandastone
added a commit
to nandastone/vue-draggable-plus
that referenced
this pull request
Apr 13, 2026
Externalize sortablejs as a peer dependency instead of bundling it into the dist. Consumers share a single sortablejs instance, so plugin registration via Sortable.mount() works from consumer code. Add three SortableJS plugins (src/plugins.ts) mounted at module load: - CloneGhost: destination-specific drag preview on cross-list entry. - HideOnLeave: hides placeholder when cursor exits destination rect. - BodyClass: toggles body.sortable-dragging during any drag. Add draggedData reactive ref on UseDraggableReturn. Add cancellable onAdd (return false to skip auto-insert for cross-type drops). Dist is checked in so git-dep consumers get the built output. Upstream sortablejs bug: SortableJS/Sortable#2465.
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.
group.put: falseis documented as preventing a sortable from receiving elements. It works correctly for cross-list drops from other sortables, but is silently ignored when a dragged item is reverted back to its own sortable.This matters for clone-source lists (e.g. a sidebar with
pull: 'clone', put: false, sort: false), items can be dragged out as clones, but nothing should be dropped back in. Currently, dragging an item out and then hovering back over the source triggers the revert branch, which bypassescheckPutentirely and reinsertsdragElinto the source.The non-owner branch of
_onDragOvercorrectly gates ongroup.checkPut. The owner branch does not — it only checkscanSort:The asymmetry means
put: falseis enforced everywhere except the one code path where the source sortable acts as its own drop target.Proposed fix:
Add
group.checkPutto the owner branch so the revert condition mirrors the non-owner branch:This change only affects sortables that explicitly declare
put: false. The default (put: trueor unset) is unchanged becausecheckPutreturns true.