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

MaterialTreeComponent is not responding to selection change #478

Closed yuan-kuan closed 3 years ago

yuan-kuan commented 3 years ago

After upgraded to angular 6.0.0 and angular_component 1.0.1 from angular 6.0.0-alpha+1 and angular_component 0.14.0-alpha+1. I noticed a bug in nested tree with single selection.

The issue is the selected item visual stuck for the previous selected item, after I select a new item in another group. All the while the SelectionModel did return the latest single value.

Take a look at the live example: https://dart-lang.github.io/angular_components/#/material_tree. The exact example "MaterialTreeNestedSingleDemoComponent" has the same issue.

tree-visual-glitch

In my own project/testing, I actually observed all previously selected item will stuck with the selected visual even they are in the same group.

cdhermann commented 3 years ago

It looks like as if the visual marker for a selection in a tree persists in single selection mode if an item in another tree is selected.

yuan-kuan commented 3 years ago

As I am working through the potential fix for this. I realize the problem is MaterialTreeComponent does not react to selection changes.

The newly selected item will displayed as "checked" because the mouse click event will force the component to rerender itself and thus drawing the latest selection state. When user select another item in another OptionGroup, the previously selected component (in this case, the tree node component) does not know the selection has changed, and then failed to rerender itself.

yuan-kuan commented 3 years ago

Forgot to mention: This bug can be observe in another way at the Material Tree Example: MaterialTreeDropdownMultiClearDemoComponent

after selecting a few option in the tree, click the "clear all" button. You will notice that the selected state is not updated, but the selection is clearly empty.

kevmoo commented 3 years ago

@lukaszkolodziejczyk – think we should revert the OnPush change for this component?

kevmoo commented 3 years ago

@yuan-kuan – this fix for this has been published in v1.0.2