@@ -31,11 +31,19 @@ document.addEventListener('DOMContentLoaded', () => {
3131 if ( toggleIcon ) {
3232 toggleIcon . style . transform = isExpanded ? 'rotate(90deg)' : 'rotate(0deg)' ;
3333 }
34+
35+ // Update settings visibility when crossChatModule is expanded/collapsed
36+ if ( section === crossChatModule ) {
37+ updateSettingsVisibility ( ) ;
38+ }
3439 } ) ;
3540 }
3641
3742 setupCollapsible ( modulesSection ) ;
3843 setupCollapsible ( crossChatModule ) ;
44+
45+ // Ensure crossChatModule starts collapsed
46+ crossChatModule . classList . remove ( 'expanded' ) ;
3947
4048 // --- State Management ---
4149 const defaultSettings = {
@@ -85,7 +93,7 @@ document.addEventListener('DOMContentLoaded', () => {
8593 function updateUIFromState ( ) {
8694 // Main toggle
8795 enableToggle . checked = currentSettings . enabled ;
88- settingsContainer . style . display = currentSettings . enabled ? 'block' : 'none' ;
96+ updateSettingsVisibility ( ) ;
8997
9098 // Settings
9199 autosendCopyToggle . checked = currentSettings . autosendCopy ;
@@ -99,6 +107,15 @@ document.addEventListener('DOMContentLoaded', () => {
99107 }
100108 }
101109
110+ // Helper function to manage settings visibility based on both toggle state and collapsible state
111+ function updateSettingsVisibility ( ) {
112+ const isModuleExpanded = crossChatModule . classList . contains ( 'expanded' ) ;
113+ const isToggleEnabled = currentSettings . enabled ;
114+
115+ // Only show settings if both the module is expanded AND the toggle is enabled
116+ settingsContainer . style . display = ( isModuleExpanded && isToggleEnabled ) ? 'block' : 'none' ;
117+ }
118+
102119 // --- Prompt Actions ---
103120 async function refreshStoredPrompt ( ) {
104121 try {
@@ -132,7 +149,7 @@ document.addEventListener('DOMContentLoaded', () => {
132149 // --- Event Listeners ---
133150 enableToggle . addEventListener ( 'change' , ( ) => {
134151 currentSettings . enabled = enableToggle . checked ;
135- settingsContainer . style . display = currentSettings . enabled ? 'block' : 'none' ;
152+ updateSettingsVisibility ( ) ;
136153 saveModuleSettings ( ) ;
137154 } ) ;
138155
0 commit comments