File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -84,17 +84,29 @@ export class SingleSelectionController implements ReactiveController {
84
84
this . uncheckSiblings ( ) ;
85
85
}
86
86
87
- // Update for the newly added host.
88
- this . updateTabIndices ( ) ;
87
+ // Update siblings after a microtask to allow other synchronous connected
88
+ // callbacks to settle before triggering additional Lit updates. This avoids
89
+ // stack overflow issues when too many elements are being rendered and
90
+ // connected at the same time.
91
+ queueMicrotask ( ( ) => {
92
+ // Update for the newly added host.
93
+ this . updateTabIndices ( ) ;
94
+ } ) ;
89
95
}
90
96
91
97
hostDisconnected ( ) {
92
98
this . host . removeEventListener ( 'keydown' , this . handleKeyDown ) ;
93
99
this . host . removeEventListener ( 'focusin' , this . handleFocusIn ) ;
94
100
this . host . removeEventListener ( 'focusout' , this . handleFocusOut ) ;
95
- // Update for siblings that are still connected.
96
- this . updateTabIndices ( ) ;
97
- this . root = null ;
101
+ // Update siblings after a microtask to allow other synchronous disconnected
102
+ // callbacks to settle before triggering additional Lit updates. This avoids
103
+ // stack overflow issues when too many elements are being rendered and
104
+ // connected at the same time.
105
+ queueMicrotask ( ( ) => {
106
+ // Update for siblings that are still connected.
107
+ this . updateTabIndices ( ) ;
108
+ this . root = null ;
109
+ } ) ;
98
110
}
99
111
100
112
/**
You can’t perform that action at this time.
0 commit comments