angulardart / angular_components

The official Material Design components for AngularDart. Used at Google in production apps.
https://pub.dev/packages/angular_components
374 stars 123 forks source link

Fix material tree selection change detection #479

Closed yuan-kuan closed 3 years ago

yuan-kuan commented 3 years ago

This an attempt to fix #478

I suspect this is a regression caused by this commit: https://github.com/dart-lang/angular_components/commit/259039e1ee9ee540c581684e7b0cdae345dfa101. I found to this commit by going through the history to look for anything that affects change detection. And this is exactly something to do with that. Reverting these changes (removing the new lines added) will fix this issue.

Of course, I am not suggesting undoing these changes. I understand there was a warning about ChangeDetection.OnPush during the building of Angular web application since the angular 6.0.0 upgrade.

So, I thought the correct way is to make MaterialTreeNode to be aware of the selection changes, and mark itself for check.

I have tried to do this selection change detection in the parent component MaterialTreeComponent but failed to find a way to do it from there. So I resorted to do this detection in each tree node.

I have see this fix in my own reproducing project: https://github.com/yuan-kuan/angulardart-broken-tree. And also the Angular Component Example project (I forked and cloned it and tested locally in my machine.)

google-cla[bot] commented 3 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

yuan-kuan commented 3 years ago

@googlebot I signed it

kevmoo commented 3 years ago

Already fixed in https://github.com/dart-lang/angular_components/commit/424808415361305c903cf89f4d119020df65a0c2