question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dropping into self

See original GitHub issue

Describe the bug You can drag an item into it self if it has a child that accepts drop.

https://p195.p4.n0.cdn.getcloudapp.com/items/geud4ggR/d26a0b2d-f670-4252-8347-ef92a302968b.gif?v=907ccf16be512a91e317756cf823cf47

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:open
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lukasbachcommented, Feb 22, 2022

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.

1reaction
lukasbachcommented, Jan 31, 2022

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found