-
-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Describe the bug
Child nodes have incorrect depth if they tree is constructed from bottom up with more then 3 levels.
Sample tree:
graph TD
0_lvl_0-->0-0_lvl_1
0-0_lvl_1-->0-0-0_lvl_2
0-0_lvl_1-->0-0-1_lvl_2
0-0-0_lvl_2-->0-0-0-0_lvl_3
0-0-0_lvl_2-->0-0-0-1_lvl_3
Actual levels of nodes (ignore incorrect parent of 0-0-0-0 and 0-0-0-1):
graph TD
0_lvl_0-->0-0_lvl_1
0-0_lvl_1-->0-0-0_lvl_2
0-0_lvl_1-->0-0-1_lvl_2
0-0_lvl_1-->0-0-0-0_lvl_2
0-0_lvl_1-->0-0-0-1_lvl_2
Problem is caused by the fact that node level update is done only for first level of children when node is added as child to another node, but it should be done recursively.
Easy solution would be to update child levels whenever node level is changed via setLevel.
To Reproduce
Steps to reproduce the behavior:
- Create 4 level treenode hierarchy.
- Check node level of 4th level leaf node.
- Reported level should be 3 but will be 2.
Expected behavior
When adding node as child all it's children should have level updated recursively.
Also when setting node level via setLevel all it's children level should be recursively updated.
Screenshots
N/A
Smartphone (please complete the following information):
- Device: API 28 emulator
Additional context
N/A