File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -292,8 +292,25 @@ export function useTableUndo({
292292 onColumnWidthsChangeRef . current ?.( merged )
293293 }
294294 if ( action . previousFrozenColumns !== null ) {
295- onFrozenColumnsChangeRef . current ?.( action . previousFrozenColumns )
296- metadata . frozenColumns = action . previousFrozenColumns
295+ const wasColumnFrozen = action . previousFrozenColumns . includes (
296+ action . columnName
297+ )
298+ if ( wasColumnFrozen ) {
299+ const currentFrozen = getFrozenColumnsRef . current ?.( ) ?? [ ]
300+ if ( ! currentFrozen . includes ( action . columnName ) ) {
301+ const insertIndex = action . previousFrozenColumns . indexOf (
302+ action . columnName
303+ )
304+ const restoredFrozen = [ ...currentFrozen ]
305+ restoredFrozen . splice (
306+ Math . min ( insertIndex , restoredFrozen . length ) ,
307+ 0 ,
308+ action . columnName
309+ )
310+ onFrozenColumnsChangeRef . current ?.( restoredFrozen )
311+ metadata . frozenColumns = restoredFrozen
312+ }
313+ }
297314 }
298315 if ( Object . keys ( metadata ) . length > 0 ) {
299316 updateMetadataMutation . mutate ( metadata )
You can’t perform that action at this time.
0 commit comments