-
-
Notifications
You must be signed in to change notification settings - Fork 91
Illegal drag-between and drag-over is allowed with key commands #363
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
Comments
Hi! Thanks for the report. I can reproduce the issue, and will look into a solution once I have some availability. |
Thanks! |
Hi, thanks for the report. The issue should be fixed as of v2.4.3. Please let me know or reopen if something doesn't work as expected. |
Thanks! This seems to work, but there is a small lingering bug where one drop target is directly under a directory, but not in the directory, which is not a real position. The drop zone for immediately-under-the-directory also exists where it should (under all the children) but there is a zombie drop point above all the children, and above position 0 of the children (top of the list), which should not exist. |
I solve it with
Which is funny and 1/2 crazy but does work. |
Your keypress API is also not working perfectly, I am setting them to |
I'll have another look at the redundant drop target. Setting all elements in the
as prop. If what you mean is that the arrow keys still work, the arrow key keybindings are handled differently because they have a different behavior, so in the past, there was no way of disabling them. I've added an additional Also, I've seen that you mentioned in a comment that default keys conflict Windows system hotkeys. I guess you removed the comment, but do you mind sharing details on the conflict? I would be very interest if there is an actual conflict, since this should be avoided in the defaults. |
It was alt-space on windows, I was confused. I test my apps on a windows machine but have a Mac keys on my keyboard so it's confusing. I am not referring to arrow keys. CTRL-space for example persists, although my code looks exactly like yours. |
Another issue I am facing is that when I use tab to navigate to the tree, the first item that gets focussed is not really focussed, so select, dnd, etc., will not work until I use the arrow keys at least once. |
I'm really sorry to bombard you here. I am assuming you want to know all this. Let me know if I can improve these reports, or if they are needed. I am able to debug/patch/workaround most of these issues myself, I am reporting just to be helpful. |
Also my client is making significant use of this, and I can suggest he make a donation at some point. |
No worries for bombarding, thanks for the details! I will have another look at the problems you describe once I have some more time. I would be happy for a donation notice :) |
Just checking in to see if there was progress on this. |
I discussed the matter with my client and they are happy to contribute some $ to the project if that helps hurry it along some. |
Hi @marchingband. Sorry for the late reply, I was mostly focusing on other things and didn't get to prioritize RCT recently. Financial support for the development of this library is always appreciated :) I'll try to look into this further and provide you with an update until end of next week. |
@lukasbach thank you! Client made a donation, name is Argumentation_LLC. |
Hi @marchingband, I've adressed some of the points you mentioned and released the changes. This thread has become fairly long, so I hope I haven't missed anything, please let me know otherwise.
I hope I understood that bug correctly, but the keyboard-targeted drop-target at thje bottom of an expanded folder, which would drop the dragged items on the same level as the folder, directly below the folder item (and thus also below the contents of the expanded folder), will not show up anymore, so this should be fixed.
I found the issue for that, the error was that pressing the space bar also triggers a click event on a focused button element as default behavior by the browser, so this caused the same behavior as clicking on a button while pressing control. I've added special handling so that this doesn't happen when triggering a click event on a button while pressing control. The normal "space triggers click event" behavior remains unchanged in other cases, since this browser-default behavior makes sense otherwise. This can be further customized by library consumers by overwriting the
I'm not really sure what you mean or what causes this, I can't reproduce this. I have used this sample as baseline, if I move focus from the button to the tree, hotkeys like "End" to jump to the tree bottom, or space to select work fine for me. Do I misunderstand the issue and you can reproduce it on one of the storybook instances, or can you otherwise provide more details on your context that produces this issue, like a sandbox that reproduces the issue or some code excerpt maybe? |
amazing thank you so so much! |
Sure! I'll just dump some info from what I found from digging through the RCT code that affects the initial focus, that might be helpful:
|
so I have these elements to my Component (this is highly abridged).
And I have a keypress listener
If I use tab to navigate to the tree, it focuses the first item in the tree, it is outlined in blue. Looking at this, I see it is possible that this is a react quirk, maybe not your problem at all. I guess I might name it "onFocusItem doesn't fire upon tab-to-tree" |
I see. I guess the idea behind From your excerpt, it looks like this is primarily an issue because you want to keep track of the focused item and act on it even at a point when the initial focus is still on the first item. Would it help, if, instead of RCT implicitly assuming the first item is focused if no items are focused, RCT would trigger |
That patch certainly works for me, do you think it is ok to add to RCT? |
…) (#426) * feat: call onFocusItem with first item if focused item is missing (#363) * v2.5.1-alpha.0 * chore: tidy up after prerelease * feat: fix invalid droptarget at bottom of tree (#363) --------- Co-authored-by: lukasbachbot <[email protected]>
I think the patch makes sense for RCT, I've merged it into the main branch. The additional drop target when dragging via keyboards is an off-by-one error in RCT I believe, unless what you experienced is something else then what I reproduced, thanks for pointing that out. I've fixed it in the latest version. Both that and the patch regarding the initial item focus is now released as of 2.6.0. |
That's working beautifully for me thank you so much. I am noticing now that when doing a keypress drag and drop, then the right/left arrow keys do not expand/collapse branches of the tree. Is there a way i can enable that? It seems like that should work, otherwise I have to expand target sub-directories before starting the drag/drop. |
Hm, no there currently is no way for doing so. RCT currently evaluates all viable drag positions when the programmatic drag is started, so right now there are no mutations to the tree structure possible while moving the drag position with the keyboard, at least not in an easy way. |
I understand, and I now remember this part about RCT. My impression is that it is a decision to make async lazy-loading of branches possible. It seems to me that in many cases, the full tree would be loaded in RAM already, so this pattern would not apply. I wonder if an option to disable this behaviour would be useful to others as well ... it would be very confusing for a non-sighted user to drag and drop into a folder, or between folders, and we would have to publish special documentation describing this limitation. |
It's partially about that the tree might not be loaded yet, but also that when doing a keyboard-bound drag, the user uses arrow keys to navigate a flattened/linear list, and the structure of this flattened list depends on which folders are expanded or not. The behavior is actually mostly consistent with other drag use cases, since you can also not expand or collapse items while doing a mouse-bound drag. |
Thanks, I understand. Hopefully this will not be an issue for our auditors. |
Interesting. I'll try to experiment with a screen reader myself during next week. At least the accessibility tool in Chrome Devtools seems to interpret it as proper tree element, it should also be possible to change how that is rendered specifically by customizing the render props of RCT, you can use the default ones as inspiration if you want to experiment with this: https://github.com/lukasbach/react-complex-tree/blob/main/packages/core/src/renderers/createDefaultRenderers.tsx Btw, I have been working for a longer time now on a successor library for react-complex-tree, which approaches some aspects of tree features a bit more sensibly than RCT. Don't worry, I will still continue maintaining react-complex-tree and fix bugs and issues that come up, but maybe that new library is of interest to you. I didn't want to bring it up yet since it didn't have feature parity with RCT yet and particularly the keyboard-based drag-and-drop interactions weren't implemented at all, but I've taken this opportunity to bring that functionality to the new library as well, and it pretty much has feature parity now with react-complex-tree. I approached the keyboard-drag there with the aspects in mind you mentioned in this thread, so it handles expanding-while-keyboard-dragging properly and also handles other special cases better than RCT. I can of course understand if you don't want to completely exchange the library you are using, but if you are interested, the library is https://headless-tree.lukasbach.com/ and I would be very glad for feedback on that library. Details on keyboard-controlled drag are available here: https://headless-tree.lukasbach.com/features/kdnd |
When I use the mouse to drag and drop, illegal moves are not allowed, and the indicator does not show. For example if I try to drag a parent onto its own child.
When I use the key commands to do the same, the indicators do show, I am allowed to drop, and can easily break the tree.
The text was updated successfully, but these errors were encountered: