File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
apps/webapp/app/components/navigation Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -183,14 +183,30 @@ export function SideMenu({
183183 [ user . isImpersonating , preferencesFetcher ]
184184 ) ;
185185
186- // Cleanup timeout on unmount
186+ // Flush pending preferences on unmount to avoid losing the last toggle
187187 useEffect ( ( ) => {
188188 return ( ) => {
189189 if ( debounceTimeoutRef . current ) {
190190 clearTimeout ( debounceTimeoutRef . current ) ;
191191 }
192+ if ( user . isImpersonating ) return ;
193+ const pending = pendingPreferencesRef . current ;
194+ if ( pending . isCollapsed !== undefined || pending . manageSectionCollapsed !== undefined ) {
195+ const formData = new FormData ( ) ;
196+ if ( pending . isCollapsed !== undefined ) {
197+ formData . append ( "isCollapsed" , String ( pending . isCollapsed ) ) ;
198+ }
199+ if ( pending . manageSectionCollapsed !== undefined ) {
200+ formData . append ( "manageSectionCollapsed" , String ( pending . manageSectionCollapsed ) ) ;
201+ }
202+ preferencesFetcher . submit ( formData , {
203+ method : "POST" ,
204+ action : "/resources/preferences/sidemenu" ,
205+ } ) ;
206+ pendingPreferencesRef . current = { } ;
207+ }
192208 } ;
193- } , [ ] ) ;
209+ } , [ preferencesFetcher , user . isImpersonating ] ) ;
194210
195211 const handleToggleCollapsed = ( ) => {
196212 const newIsCollapsed = ! isCollapsed ;
You can’t perform that action at this time.
0 commit comments