@@ -132,6 +132,9 @@ window.MaxExtensionButtonsInit = {
132132 }
133133 }
134134 }
135+
136+ // --- Add toggles at the very end, always after everything else ---
137+ this . generateAndAppendToggles ( container ) ;
135138 } ,
136139
137140 /**
@@ -163,9 +166,8 @@ window.MaxExtensionButtonsInit = {
163166 const isPanel = targetContainer . id === 'max-extension-floating-panel-content' ;
164167
165168 // Append custom send buttons, passing the context.
169+ // Note: toggles are now appended within generateAndAppendAllButtons() at the very end
166170 this . generateAndAppendAllButtons ( customElementsContainer , isPanel ) ;
167- // Append toggle switches
168- this . generateAndAppendToggles ( customElementsContainer ) ;
169171
170172 targetContainer . appendChild ( customElementsContainer ) ;
171173 logConCgp ( '[init] Custom elements have been inserted into the DOM.' ) ;
@@ -182,8 +184,8 @@ window.MaxExtensionButtonsInit = {
182184 // Clear existing buttons and toggles
183185 originalContainer . innerHTML = '' ;
184186
187+ // Note: toggles are now appended within generateAndAppendAllButtons() at the very end
185188 this . generateAndAppendAllButtons ( originalContainer , false ) ; // Not panel
186- this . generateAndAppendToggles ( originalContainer ) ;
187189
188190 logConCgp ( '[init] Updated buttons in original container for profile change.' ) ;
189191 }
@@ -195,8 +197,8 @@ window.MaxExtensionButtonsInit = {
195197 // Clear existing buttons and toggles
196198 panelContent . innerHTML = '' ;
197199
200+ // Note: toggles are now appended within generateAndAppendAllButtons() at the very end
198201 this . generateAndAppendAllButtons ( panelContent , true ) ; // This is the panel
199- this . generateAndAppendToggles ( panelContent ) ;
200202
201203 logConCgp ( '[init] Updated buttons in floating panel for profile change.' ) ;
202204 }
0 commit comments