@@ -59,14 +59,7 @@ export class UUIRadioGroupElement extends FormControlMixin(LitElement) {
59
59
if ( newValue === null || newValue === '' ) {
60
60
this . _makeFirstEnabledFocusable ( ) ;
61
61
}
62
- this . _radioElements . forEach ( ( el , index ) => {
63
- if ( el . value === newValue ) {
64
- el . checked = true ;
65
- this . _selected = index ;
66
- } else {
67
- el . checked = false ;
68
- }
69
- } ) ;
62
+ this . _updateRadioElementsCheckedState ( newValue ) ;
70
63
}
71
64
72
65
private _selected : number | null = null ;
@@ -75,6 +68,11 @@ export class UUIRadioGroupElement extends FormControlMixin(LitElement) {
75
68
super ( ) ;
76
69
this . addEventListener ( 'keydown' , this . _onKeydown ) ;
77
70
this . addEventListener ( 'keypress' , this . _onKeypress ) ;
71
+
72
+ // Wait for the radio elements to be added to the dom before updating the checked state.
73
+ this . updateComplete . then ( ( ) => {
74
+ this . _updateRadioElementsCheckedState ( this . value ) ;
75
+ } ) ;
78
76
}
79
77
80
78
connectedCallback ( ) {
@@ -112,6 +110,19 @@ export class UUIRadioGroupElement extends FormControlMixin(LitElement) {
112
110
this . _radioElements ?. forEach ( el => ( el . name = name ) ) ;
113
111
}
114
112
113
+ private _updateRadioElementsCheckedState (
114
+ newValue : FormData | FormDataEntryValue
115
+ ) {
116
+ this . _radioElements . forEach ( ( el , index ) => {
117
+ if ( el . value === newValue ) {
118
+ el . checked = true ;
119
+ this . _selected = index ;
120
+ } else {
121
+ el . checked = false ;
122
+ }
123
+ } ) ;
124
+ }
125
+
115
126
private _setDisableOnRadios ( value : boolean ) {
116
127
this . _radioElements ?. forEach ( el => ( el . disabled = value ) ) ;
117
128
}
0 commit comments