-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUGFIX: Insert copied or moved nodes in order of selection #3708
Conversation
I keep this for now as draft, as I have to check the move operations too. |
🎥 End-to-End Test Recordings These videos demonstrate the end-to-end tests for the changes in this pull request. |
Now debatable why |
This is not an elegant change, but I'm out of ideas right now how to do it better without a larger code change that would introduce "batch changes" which carry more information about the ordering of elements. |
Okay i tested now without this fix first and that were my results: #3040 (comment)
✅ = expected order like the nodes arranged in the ui So the problem with this fix is, the workaround that is currently used to select the nodes from bottom to top will be now reserved which is also mindblowing? |
$parentNode = $this->getParentNode(); | ||
$nodeName = $this->generateUniqueNodeName($parentNode); | ||
// If the parent node has children, we copy the node after the last child node to prevent the copied nodes | ||
// from being mixed with the existing ones due the duplication of their relative indices. | ||
if ($parentNode->hasChildNodes()) { | ||
$lastChildNode = array_slice($parentNode->getChildNodes(), -1, 1)[0]; | ||
$node = $this->getSubject()->copyAfter($lastChildNode, $nodeName); | ||
} else { | ||
$node = $this->getSubject()->copyInto($parentNode, $nodeName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhsdesign thx for the thorough testing! I wouldn't do anything about the clipboard order issue as this would be a larger change we can check separately if we can implement this as a fix or feature for future Neos or keep it like it is. |
We found out that my testing uncovered another problem. Shift click and command click behave different |
OK after a screen share session we found out that there is a difference behaviour on how items are added to the clipboard depending whether one uses Command+Select or Shift+Select. The later seems to add them in the incorrect order to the clipboard and therefore the resulting result of the insert operation seems again random. |
@mhsdesign my latest change fixes that RangeSelect behaviour |
EDIT: The descriptions in this comment are based on false assumptions about the requirements in this PR. For clarification see: #3708 (comment) Hi @Sebobo, I have tried to compile some E2E tests for this problem. The original issue #3040 focuses on move and copy operations for content nodes. I based my tests on the existing tests for the document tree, but I expect this to translate well to the content tree. This way I was able to to write up a comprehensive set of cases. Since this problem space has a couple of dimensions, I ended up with 45 different scenarios. Those test cases alone run for quite a while (~8min on my machine), which is - amongst some other, minor problems - why I didn't push the test code right away. Nevertheless, I still wanted to share my findings. Since there are lots of parameters, I'll start by describing some background assumptions for the tests: Let's suppose, we have the following simplified document tree:
For the first part of the test matrix, we need to distinguish between two methods of selecting multiple nodes (
The second part of the test matrix concerns the operations a user can perform with a selection of multiple nodes. Those are basically The following tables illustrate what the resulting page tree (given the tree from above) is expected to look like after each operation: Scenario: Move
Scenario: Copy
Based on these assumptions, I ran my 45 test cases on both the Test results on branch
Test results on branch
Both test runs result in 27 cases failing (though different cases fail). I'm not sure whether it would be feasible to fix all those cases. If so, I'm also not sure whether it would be wise to add all cases to our test suite - because that's +8min on all CI runs :/ But I hope that I could give some insight 😅 (I will share the test code as well of course - I'll probably open a separate PR, so it doesn't clutter up this one) |
Hi @grebaldi, wow, thx for the thorough test! The intention of the PR is actually for the bottom-to-top case to also reflect the bottom-to-top order and not invert it to top-to-bottom. Of course this is debatable, but I somehow preferred keeping the order of selection. This should make most cases green except the random one. |
That was exactly the same thought when I saw the e-mail yesterday in the evening. Just WOW, and thank you @grebaldi for all your detailed descriptions and comments. You are so valuable and awesome :) |
Yes hats of to your testings @grebaldi :D Also it seems your tests uncovered that |
Whoops, how did I miss that? Sorry for the confusion, I should have guessed the intention from the title of this PR 🤦 Well, my intuition went exactly the other way 😅, but I understand the technical limitations of course. So, just to clearify the expected behavior given the tree:
If we CMD-Click-select first
(With all other cases resulting in an analogous order?) If so, I will adjust my test cases accordingly and report back :)
Well, there's
It may be possible to run some of the tests conditionally. I believe we can tell Circle CI / Github Actions to filter the tests based on whether a specific label is set on the PR. Or maybe we could run specific tests by prompting some bot? Don't know exactly how to set up something like that, but it would allow us to keep the average push/PR test-runs small and only run more thourough tests when they're actually needed. For the release branches, we could run the entire, much more comprehensive test suite which would greatly increase our certainty. |
Yes |
Here are the updated test results: Test results on branch
Test results on branch
There are only 12 remaining failures. Almost the entire |
@grebaldi thx for the update :) I will check on the drag & drop, I didn't even expect it to behave different so I didn't test it before 😔 |
5ed9fe9
to
f552dae
Compare
@grebaldi I finally got to make the adjustment for the drag & drop part. With that The remaining red crosses are checks for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3040 Selection order of nodes is preserved when selecting multiple tree-nodes...
✓ ...in top-down order via CMD-click and moving them AFTER another node via DND
✓ ...in top-down order via CMD-click and moving them BEFORE another node via DND
✓ ...in top-down order via CMD-click and moving them INTO another node via DND
✓ ...in top-down order via CMD-click and moving them AFTER another node via Cut&Paste
✓ ...in top-down order via CMD-click and moving them BEFORE another node via Cut&Paste
✓ ...in top-down order via CMD-click and moving them INTO another node via Cut&Paste
✓ ...in top-down order via CMD-click and copying them AFTER another node via Copy&Paste
✓ ...in top-down order via CMD-click and copying them BEFORE another node via Copy&Paste
✓ ...in top-down order via CMD-click and copying them INTO another node via Copy&Paste
✓ ...in bottom-up order via CMD-click and moving them AFTER another node via DND
✓ ...in bottom-up order via CMD-click and moving them BEFORE another node via DND
✓ ...in bottom-up order via CMD-click and moving them INTO another node via DND
✓ ...in bottom-up order via CMD-click and moving them AFTER another node via Cut&Paste
✓ ...in bottom-up order via CMD-click and moving them BEFORE another node via Cut&Paste
✓ ...in bottom-up order via CMD-click and moving them INTO another node via Cut&Paste
✓ ...in bottom-up order via CMD-click and copying them AFTER another node via Copy&Paste
✓ ...in bottom-up order via CMD-click and copying them BEFORE another node via Copy&Paste
✓ ...in bottom-up order via CMD-click and copying them INTO another node via Copy&Paste
✓ ...in a random order via CMD-click and moving them AFTER another node via DND
✓ ...in a random order via CMD-click and moving them BEFORE another node via DND
✓ ...in a random order via CMD-click and moving them INTO another node via DND
✓ ...in a random order via CMD-click and moving them AFTER another node via Cut&Paste
✓ ...in a random order via CMD-click and moving them BEFORE another node via Cut&Paste
✓ ...in a random order via CMD-click and moving them INTO another node via Cut&Paste
✓ ...in a random order via CMD-click and moving them AFTER another node via Copy&Paste
✓ ...in a random order via CMD-click and copying them BEFORE another node via Copy&Paste
✓ ...in a random order via CMD-click and copying them INTO another node via Copy&Paste
✓ ...in top-down order via SHIFT-click and moving them AFTER another node via DND
✓ ...in top-down order via SHIFT-click and moving them BEFORE another node via DND
✓ ...in top-down order via SHIFT-click and moving them INTO another node via DND
✓ ...in top-down order via SHIFT-click and moving them AFTER another node via Cut&Paste
✓ ...in top-down order via SHIFT-click and moving them BEFORE another node via Cut&Paste
✓ ...in top-down order via SHIFT-click and moving them INTO another node via Cut&Paste
✓ ...in top-down order via SHIFT-click and copying them AFTER another node via Copy&Paste
✓ ...in top-down order via SHIFT-click and copying them BEFORE another node via Copy&Paste
✓ ...in top-down order via SHIFT-click and copying them INTO another node via Copy&Paste
✓ ...in bottom-up order via SHIFT-click and moving them AFTER another node via DND
✓ ...in bottom-up order via SHIFT-click and moving them BEFORE another node via DND
✓ ...in bottom-up order via SHIFT-click and moving them INTO another node via DND
✓ ...in bottom-up order via SHIFT-click and moving them AFTER another node via Cut&Paste
✓ ...in bottom-up order via SHIFT-click and moving them BEFORE another node via Cut&Paste
✓ ...in bottom-up order via SHIFT-click and moving them INTO another node via Cut&Paste
✓ ...in bottom-up order via SHIFT-click and copying them AFTER another node via Copy&Paste
✓ ...in bottom-up order via SHIFT-click and copying them BEFORE another node via Copy&Paste
✓ ...in bottom-up order via SHIFT-click and copying them INTO another node via Copy&Paste
👍 🎉 👍
Thanks a lot for the effort, @Sebobo!
Though I couldn't reproduce the issue you had with the "before" and "into" column which both worked fine for me, [...]
The "before"-column is now green - so no issues there. The two red ones in the "into"-column were - as I now realized after revisiting the tests - in fact my fault. Those were most likely copy&paste errors - I seem to have lost track given the amount of scenarios. My apologies for that! I hope this didn't cause you too much trouble.
f552dae
to
ceeccbc
Compare
This reverses the order of nodes for
insertAfter
(copy & move) operations to prevent the reverse order of insertion due to the way the atomic inserts are done by the change operations.Also turns
insertInto
internally into ainsertAfter
if the selected target parent node already has children. Here the reversion is not necessary as always the last child node is picked to "insert after" and therefore keeping the order of the users selection (clipboard).Resolves: #3040