angular-tree-component
angular-tree-component copied to clipboard
After call function treeModel.update(), the scrollbar moves to top
Hi, I recently discovered this bug. If I call function treeModel.update()
inside event activate
on tree the scrollbar scrolls to the top of the tree.
I want to load more children using node 'Show more'. 'Show more' is the last visible leaf. After click on 'Show more' node I added child nodes to parent node model and call treeModel.update() function
public onActivate($event: any) { if ($event.node.data.isShowMore) { const parent = $event.node.parent.data as TestItemNode; if (parent) { parent.loadMore(); //add TestItemNode[] to children collection this.treeComponent.treeModel.update(); } } }
Current behaviour:
After call this.treeComponent.treeModel.update()
the scrollbar scrolls to the top
Expected behaviour:
After call function this.treeComponent.treeModel.update()
the scrollbar stays on the same position
Reproduce
-
Expand tree
-
Scroll to the bottom of the page
-
Click on child node at the bottom of the tree
Results:
- Tree is scrolled to the top
Expected results
- Scrollbar stayed on the same position
Note:
If I click on 'End' title and call treeModel.update()
the scrollbar isn't jumping
https://stackblitz.com/edit/angular-okp7ix
Additional Info
- Paste your package.json - "angular-tree-component": "^8.2.0" (everything you can see in the StackBlitz repro)
- Which browser - Chrome 71, FF 65
Related #704
add scrollOnActivate: false
to treeOptions might be an option.
don't know why you actually want to have scroll onActivate but that's how you can disable it.