Comments (7)
What exactly would be the behavior that you are looking for? If the last tree is expanded, the bottom-most drag-position can only have one implementation. If we don't have it move to the final inner-most folder, it makes it very unclear where the item should go. For example, consider a structure where the user drags the "a" item to the bottom-most location
- a
- b
- c
-d
-e
At the moment, it would move the item into the bottom-most folder, so d, or e if e is an expanded folder with no items. If we don't want that, where should the item go then? c? or b? or into the root folder?
The current behavior matches the implementation that Microsoft's WinUI follows. I'm not sure what other good examples of established implementations exist, but I'm happy to see other examples of how this is done otherwise in practice.
from react-complex-tree.
We are also finding this issue. It is currently an inconsistent interaction as you can move items below an expanded item elsewhere in the tree (due to the 2 hover zones when there is an item beneath).
Figmas layers tree get's this right and might be a better reference than WinUI as it is very inconvenient to have to close the above tree to be able to drag something to the bottom, particularly when this interaction is possible elsewhere in the tree.
from react-complex-tree.
I agree, but if the user drags at the bottom-most location, it can only target one possible target. The Figma example looks like a great solution, but also seems to approach the problem differently, by including the horizontal mouse position in the decision of where the item is dropped at. I honestly don't see that as that realistic for this library for a number of reasons, being that horizontal position is dependent on the item indendation, which is based on the custom render logic of the library consumer and might not be available to the library; the drop determination logic is already very complicated and will get even more hard to maintain if horizontal position is also included; and it would affect the logic for drop targets at other locations as well.
from react-complex-tree.
Whilst the figma-style horizontal interaction is certainly the ideal way to interact with a tree. The fact that react-complex-tree is capable of discerning between "Place below this open tree" and "Place inside this open tree" elsewhere in the tree (as long as there is at least element beneath) suggests a less complex solution may still be available. Would it be possible for example to add an invisible drop zone at the very bottom of the list such that the behaviour is more consistent with how interactions work elsewhere in the tree?
from react-complex-tree.
Hm yes that should be possible, there actually already is logic to catch drop events at the bottom of the tree, they are just interpreted as dropping on the bottom of the bottom-most item. I changed it to the behavior you suggested, you can try it out in this example: https://rct.lukasbach.com/storybook/?path=/story/core-basic-examples--drop-on-empty-tree
If you want to use this yourself, you need to make sure that the component rendered by renderTreeContainer
actually fills the height of the full drop container, so that there is space at the bottom of the tree to drop at.
Is this solution closer to what you expect?
from react-complex-tree.
In our case we're only allowing one type of item at the root level which can only exist at the root level, so this solution unfortunately does not work for us
Would it be possible to expose the item indent amount as a prop on the tree environment which either accepts a static number
value for uniform depth indentation or a callback which calls with the current depth
and DraggingPosition
similar to the canDropAt
callback?
from react-complex-tree.
@tonyketcham can you elaborate a bit on the prop you propose, I'm not sure I understand what you suggest it should do.
from react-complex-tree.
Related Issues (20)
- DROP not working when open a new folder. HOT 3
- Customize Cursor when Dragging HOT 1
- Example for drag and drog with controlled tree? HOT 1
- Request for `context.stopRenamingItem(item.index)` as counter for existing startRenamingItem function HOT 2
- Cannot read properties of undefined (reading 'index') HOT 3
- tree update HOT 1
- Drag custom files to the tree HOT 2
- Text selection on title don't work HOT 3
- Missing `activeTreeId` in `TreeEnvironmentRef<T,C>` type HOT 1
- Set state on unmounted component HOT 8
- Tree is missing `multiselect` prop HOT 2
- I want to print node contents. HOT 1
- Unable to update tree data using custom Data Provider HOT 3
- Collision with react-dnd HOT 2
- Search whole tree HOT 5
- Animation when node is opened and closed HOT 3
- `renderItem` and `renderItemTitle` rerenders causes performance hits HOT 1
- customize keyboard bindings HOT 1
- Custom search HOT 1
- Expand tree element without selecting it HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-complex-tree.