@@ -61,8 +61,8 @@ class MaterialRadioGroupComponent
6161 // by focus calls.
6262 _resetTabIndex ();
6363 _selected = _selectedRadioComponent? .value;
64- if (valueSelection != null && _selected != null ) {
65- valueSelection .select (_selected);
64+ if (_valueSelection != null && _selected != null ) {
65+ _valueSelection .select (_selected);
6666 }
6767 _onChange.add (_selected);
6868 }));
@@ -141,7 +141,19 @@ class MaterialRadioGroupComponent
141141
142142 /// Selection model containing value object.
143143 @Input ('selectionModel' )
144- SelectionModel valueSelection;
144+ set valueSelection (SelectionModel value) {
145+ if (_valueSelection == value) return ;
146+ _selectionSubscription? .cancel ();
147+ _valueSelection = value;
148+ _selectionSubscription = _valueSelection? .selectionChanges? .listen ((_) {
149+ selected = _valueSelection.selectedValues
150+ .firstWhere ((_) => true , orElse: () => null );
151+ });
152+ }
153+
154+ SelectionModel _valueSelection;
155+ StreamSubscription <List <SelectionChangeRecord <dynamic >>>
156+ _selectionSubscription;
145157
146158 /// Internal selection model containing the radio component.
147159 final componentSelection = SelectionModel <MaterialRadioComponent >.single ();
@@ -225,5 +237,6 @@ class MaterialRadioGroupComponent
225237 @override
226238 void ngOnDestroy () {
227239 _disposer.dispose ();
240+ _selectionSubscription? .cancel ();
228241 }
229242}
0 commit comments