Drag-dropping a node in the same position and container no longer rem…#485
Merged
Conversation
…oves and re-adds it to its parent node array
Member
|
Thanks for your contribution! I've tested this locally, looking good. 👍 |
Voles
pushed a commit
that referenced
this pull request
Jul 8, 2015
Drag-dropping a node in the same position and container no longer rem…
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.
The drag-drop apply function in its current form removes an element from its collection and then re-inserts it in its final place. This is normally fine, except when dragging and dropping a node into the same place. In this case, the node hasn't moved, but removing and reinserting the node can have side effects.
In my use case, we're using another library (BreezeJs) to perform automatic change detection. When dropping a node without moving, this causes simply clicking a draggable node to trigger change detection and improperly identify the node as changed.
This PR checks if the node is being dropped into the same container and index as it started in, and then returns without manipulating the node's place in its collection.