Repository navigation
Conversation
When an item is dragged out of its own grid (past the edge, or over a grid that doesn't accept it), _leave() removes it from the engine, so cancelDrag() -> engine.restoreInitial() only restores the other nodes. onEndMoving() then re-adds the item at its last position (not _orig), pushing the just restored nodes again. cancelDrag() now resets such an item back to its _orig position, which onEndMoving() adds it back at.
This branch has not been deployed
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
Pressing
Escdoesn't revert a drag once the item has left its own grid (dragged past the grid edge, or over a grid that doesn't accept it): the item stays at its last position inside the grid and the nodes it pushed stay moved, and achangeevent is sent.Steps (any grid with
acceptWidgets: true): dragaover its neighbourbsobgets pushed, keep dragging out of the grid, pressEsc—alands onb's old spot andbstays pushed.Cause:
_leave()removes the node from the engine (_temporaryRemoved), socancelDrag()->engine.restoreInitial()restores only the other nodes.onEndMoving()then re-adds the node at its last tried position (not_orig), pushing the just restored nodes again.Fix: in
cancelDrag(), a node of ours that was temporarily removed is reset back to its_origposition, whichonEndMoving()adds it back at.Related but not fixed here: #2933 (Esc while over another grid that accepts the item).
Checklist
e2e/cancelled-drag-after-leave.spec.ts(float: falseandtrue), fails on masteryarn test) —vitest446/446,tsc+eslint src; the 6 failures ine2e/gridstack-e2e.spec.ts(getGrids is not a function) are the same on master