-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs-bug(treeview): Add guide on how to migrate from old treeview to new treeview #29919
Comments
Actually, the tree documentation page needs some attention overall it seems. In the v17 documentation, the "Tree with flat nodes" appears correct. But then, in v 18.2.10, it looks wrong. I think I'm reasonably good at the tree - I did an implementation for work and also wrote a fairly long article for LogRocket so I might be able to pop in a PR for these things, and fix other things (https://blog.logrocket.com/angular-tree-flat-vs-nested-and-more/). Also, the various selectors seem to rely on knowing about the children beforehand and don't support returning asynchronously. When tree children are loaded from the server, how is this supposed to be handled? Kind of not really related - I find the documentation for the treeview to be simultaneously overwhelming and light on details, almost like it's been built up over several years. This confusion is now only worse with the API documentation chopping and changing between the old |
Just to help other people who might be trying to use async data in their trees: I figured it out. I tried a lot of things and in the end this is what stuck. My branch is here, I'm going to write about it soon with samples etc: https://github.com/azimuthdeveloper/angulartree/tree/inflight-changes-to-new-angular-tree Basically, For flat trees, use levelAccessor, and then on your node, use For nested trees, use childAccessor, and assign it to the
Again, then on your node, use On a more personal note, I think Angular has been going from strength to strength lately, and I wouldn't want to get on here and complain or say anything derogatory. Please accept this as constructive feedback. At the time of me writing this, the tree control sample page is an unintelligible mess, chopping back and forth between the old treeControl and new childrenAccessor/levelAccessor. The documentation was very hard to understand in the first place and now it's just gotten worse. There are samples on how to use childrenAccessor, but no samples on how to use levelAccessor, so people are free to guess their way through an implementation like I did. It's not clear why the tree was revamped - I couldn't find a long issue with comments that ended in "okay I'm going to deprecate large parts of the tree and make it work differently" so it's difficult to understand why this change was even made in the first place. It would be nice if, when new features shipped, there was a better copy-edit process on the documentation, documentation didn't ship with todo notes, documentation was at least at feature parity with previous releases (like async loading of nodes), documentation at least covered all features (such as levelAccessor being absent) and some rationale was given as to why the change occured. I'm a strong Angular supporter, I write about it professionally and use it in my day job, so this comes from a place where I want Angular to succeed in the long run. |
I almost totally agree with you @azimuthdeveloper about the lack of documentation. Just one point to be fair: the new code to use |
To remark on why the tree changed, in short we had a number of accessibility issues with how the tree worked in the past. As we made changes to improve the accessibility, we had to make adjustments/improvements to the API. You can see a detailed note of the changes and their reasons in the original PR #29062 I agree the tree's documentation is subpar. Unfortunately we ran out of resources to give it the update it deserves. In particular I do wish we had a better guide on transitioning from the deprecated API to the current. |
Documentation Feedback
Following the sudden deprecation of the various tree controllers, it would be nice if there were some kind of documentation on how to remove tree controller and migrate to the new way of doing things. Also, the documentation still contains references to
treeControl
, which it shouldn't because the treeControl has been deprecated?A simple migration guide would be warranted as well because there are tonnes of search results and guides on how to use the tree that just became out of date, so if there was an easy way to adapt code to the new way of doing things, that would be ideal.
Affected documentation page
https://material.angular.io/components/tree/overview
The text was updated successfully, but these errors were encountered: