Dropping into self
See original GitHub issueDescribe the bug You can drag an item into it self if it has a child that accepts drop.
Expected Disallow this sort of thing.
canDropAt={(items, target) => {
// prevent self drop
if(items[0].index == target.parentItem) return false
// check if target is a child of parent
const isSelf = itemsSource[items[0].index].children.findIndex(i => i == target.parentItem)
if(isSelf !== -1) return false
return true
}
}
That is some basic code to check. If the fist item is the same as the a parent. I also check if parentItem is a child of the first item checking the items. (I called it itemsSource).
This isn’t great and doesn’t check for multiple selects. But it kind of works. 😃
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Ego Dropping: The Magic of Breaking Free from Self-Concern
Sit still and notice how your body feels · When your mind wanders, bring it back to the present · Open your awareness...
Read more >Dropping Your Self | Toby Ouvry Meditation
You drop all the labels that you usually associate with your idea of who you are; job title, gender, pretty/ugly, strong/weak (etc), position...
Read more >Dying To Self - Dropping Your Ego - Zen Tools
Dying to self and dropping the ego is not a one-time experience but a frequent activity that should be undertaken at least daily...
Read more >Drop into Your Best Self
In individual and group sessions, we aspire to inspire, guide, and support participants in the process of becoming big, full, and complete -...
Read more >▷ How dropping your ego brings out your best version
Dropping the ego is the most effective way to cultivate personal well-being, have a balanced self-esteem, be more productive and enjoy a fuller...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @C7X! When working with lists with thousands of entries, list virtualization starts to become inevitable. This is something I want to support with react-complex-tree in the future, but there is still a bigger road ahead for that and that will not come with the performance fixes I am working on right now, sorry. So for now, I unfortunately have to say that other libraries might be a better starting point until rct supports virtualization.
Hi, thanks for reporting! Just as an heads up, I’ve looked into it, and it is not quite as trivial to fix; since checking whether someone is dropping an item into itself is not a trivial operation (can be a high depth through which is being dropped, and arbitrarily many items can be dragged at once, so the check is required for every dragged item), this will require some calculation. And, currently, the drop check happens on the drag event, not the drop event (so that the library can already prevent dropping on not allowed items), so this might not scale well for bigger trees. I’m currently working on improving the overall performance of the library, and then plan to only do the check during the initial drag event, hopefully in a way that only requires linear effort. Until then, a workaround similar to what @impactvelocity suggested is probably the easiest way to go. I’ll keep you updated on the progress!