flame icon indicating copy to clipboard operation
flame copied to clipboard

Removed children are added again if parent component is moved to other parent

Open ASGAlex opened this issue 2 years ago • 4 comments

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

  1. Create a component with a child
  2. Add it to one parent
  3. Then in one update cycle remove the child from component and change component's parent
  4. 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

ASGAlex avatar Dec 14 '23 23:12 ASGAlex

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 avatar Dec 15 '23 04:12 spydon

@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.

ASGAlex avatar Dec 16 '23 00:12 ASGAlex

Ah yes, so it's in the same tick, that was the info I was missing :)

spydon avatar Dec 16 '23 10:12 spydon

I did not research it deeply, but it might be also triggered by multiple tree modifications in same tick

image

ASGAlex avatar Jan 20 '24 19:01 ASGAlex