Open MurzNN opened 2 years ago
@MurzNN the issue is in outdated data. addChild
method updates the variable with the child node, but doesn't update other variables. You need to update a variable with a parent node before using it (calling addChild
and other methods).
let tagElectronics = new Tag(); tagElectronics.label = 'Electronics';
tagElectronics = await Tag.createRoot(tagElectronics);
let tagPhones = new Tag(); tagPhones.label = 'Phones';
await tagElectronics.addChild(tagPhones);
await tagElectronics.reload();
let tagTVs = new Tag(); tagTVs.label = 'TVs';
await tagElectronics.addChild(tagTVs);
let tagSamsung = new Tag(); tagSamsung.label = 'Samsung';
await tagTVs.addChild(tagSamsung);
await tagTVs.reload();
let tagApple = new Tag(); tagApple.label = 'Apple';
await tagTVs.addChild(tagApple);
await tagPhones.reload();
let tagXiaomi = new Tag(); tagXiaomi.label = 'Xiaomi';
await tagPhones.addChild(tagXiaomi);
As example I'm trying to create
Tag
nested set with tree structure like this:Here is the code:
But as result I see that
Xiaomi
item is placed in wrong parent branch! Here is output:Can you please describe why this happens? Maybe some code parts are wrong?