@@ -54,18 +54,6 @@ export class RadioGroup<T = any> extends FormControlMixin(LitElement) {
5454  /** The initial state when the form was associated with the radio group. Used to reset the group. */ 
5555  #initialState?: T ; 
5656
57-   /** 
58-    * Stores the initial value of the radio group when it is first rendered. 
59-    * Used to determine if the value has changed since initialization and to manage event emission, avoiding unnecessary events on the first render. 
60-    */ 
61-   #initialValue?: T ; 
62- 
63-   /** 
64-    * Indicates whether the component is rendering for the first time. 
65-    * Used to track the initial render and preventing unnecessary event emission. 
66-    */ 
67-   #isInitialRender =  true ; 
68- 
6957  /** When an option is checked, update the state. */ 
7058  #observer =  new  MutationObserver ( mutations  =>  { 
7159    const  {  target }  =  mutations . find ( m  =>  m . attributeName  ===  'checked'  &&  m . oldValue  ===  null )  ||  { } ; 
@@ -189,11 +177,6 @@ export class RadioGroup<T = any> extends FormControlMixin(LitElement) {
189177    } 
190178
191179    if  ( changes . has ( 'value' ) )  { 
192-       if  ( this . #isInitialRender)  { 
193-         this . #initialValue =  this . value ; 
194-         this . #isInitialRender =  false ; 
195-       } 
196- 
197180      this . #observer. disconnect ( ) ; 
198181      this . radios ?. forEach ( radio  =>  ( radio . checked  =  radio . value  ===  this . value ) ) ; 
199182      this . #observer. observe ( this ,  OBSERVER_OPTIONS ) ; 
@@ -223,10 +206,12 @@ export class RadioGroup<T = any> extends FormControlMixin(LitElement) {
223206    this . updateState ( {  touched : true  } ) ; 
224207  } 
225208
226-   #onSlotchange( ) : void { 
209+   async   #onSlotchange( ) : Promise < void >  { 
227210    this . #rovingTabindexController. clearElementCache ( ) ; 
228211
229-     this . radios ?. forEach ( radio  =>  { 
212+     this . #observer. disconnect ( ) ; 
213+ 
214+     for  ( const  radio  of  this . radios  ??  [ ] )  { 
230215      radio . checked  =  radio . value  ===  this . value ; 
231216
232217      if  ( typeof  this . disabled  ===  'boolean' )  { 
@@ -236,22 +221,24 @@ export class RadioGroup<T = any> extends FormControlMixin(LitElement) {
236221      if  ( this . size )  { 
237222        radio . size  =  this . size ; 
238223      } 
239-     } ) ; 
224+ 
225+       // Wait for the `<sl-radio>` to stabilize, otherwise we'll trigger the observer 
226+       await  radio . updateComplete ; 
227+     } 
228+ 
229+     this . #observer. observe ( this ,  OBSERVER_OPTIONS ) ; 
240230  } 
241231
242232  #setSelectedOption( option ?: Radio < T > ,  emitEvent  =  true ) : void { 
243233    this . radios ?. forEach ( radio  =>  ( radio . checked  =  radio . value  ===  option ?. value ) ) ; 
244234    this . value  =  option ?. value ; 
245235
246236    if  ( emitEvent )  { 
247-       if  ( ! this . #initialValue)  { 
248-         this . changeEvent . emit ( this . value ) ; 
249-       } 
237+       this . changeEvent . emit ( this . value ) ; 
250238      this . updateState ( {  dirty : true  } ) ; 
251239    } 
252240
253241    this . #updateValueAndValidity( ) ; 
254-     this . #initialValue =  undefined ; 
255242  } 
256243
257244  #updateValueAndValidity( ) : void { 
0 commit comments