Skip to content

Commit f1a89ea

Browse files
committed
Refactor toggle initialization: append toggles at the end of button generation to ensure proper order
1 parent 4dfea38 commit f1a89ea

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

buttons-init.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)