Removed children are added again if parent component is moved to other parent
Current bug behavior
Removed childrent are re-added into component whish moved from one parent to another at same update cycle.
Expected behavior
Removed components are removed. They should not be re-added again it this is not requested by user explicitly
Steps to reproduce
- Create a component with a child
- Add it to one parent
- Then in one update cycle remove the child from component and change component's parent
- in next update cycle you will see that removed child is added to the component again due to _reAddChildren call
More information
_reAddChildren chould have a list of exceptions with all removed components inside to avoid adding it again
Can you post a full MRE? This sounds very unlikely that it wouldn't have been reported before. Is it happening in some edge case?
@spydon take a look on the commit above. This simple test should not fail. But it fails.
The reason is simple: while moving components from one parent to another it's children are not re-added immediately, instead everything is passed to the queue. So adding operation is performed just after removing operation, the queu just does not care about it.
Ah yes, so it's in the same tick, that was the info I was missing :)
I did not research it deeply, but it might be also triggered by multiple tree modifications in same tick