mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-01 02:05:18 -05:00
fix(undo-redo): use consistent target state for toggle redo
The redo logic for BATCH_TOGGLE_ENABLED and BATCH_TOGGLE_LOCKED was incorrectly computing each block's new state as !previousStates[blockId]. However, the store's batchToggleEnabled/batchToggleLocked set ALL blocks to the SAME target state based on the first block's previous state. Now redo computes targetState = !previousStates[firstBlockId] and applies it to all blocks, matching the store's behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1447,10 +1447,12 @@ export function useUndoRedo() {
|
||||
userId,
|
||||
})
|
||||
|
||||
// Use setBlockEnabled to directly set to toggled state
|
||||
// Redo sets to !previousStates (the state after the original toggle)
|
||||
// Compute target state the same way batchToggleEnabled does:
|
||||
// use !firstBlock.enabled, where firstBlock is blockIds[0]
|
||||
const firstBlockId = blockIds[0]
|
||||
const targetEnabled = !previousStates[firstBlockId]
|
||||
validBlockIds.forEach((blockId) => {
|
||||
useWorkflowStore.getState().setBlockEnabled(blockId, !previousStates[blockId])
|
||||
useWorkflowStore.getState().setBlockEnabled(blockId, targetEnabled)
|
||||
})
|
||||
break
|
||||
}
|
||||
@@ -1505,10 +1507,12 @@ export function useUndoRedo() {
|
||||
userId,
|
||||
})
|
||||
|
||||
// Use setBlockLocked to directly set to toggled state
|
||||
// Redo sets to !previousStates (the state after the original toggle)
|
||||
// Compute target state the same way batchToggleLocked does:
|
||||
// use !firstBlock.locked, where firstBlock is blockIds[0]
|
||||
const firstBlockId = blockIds[0]
|
||||
const targetLocked = !previousStates[firstBlockId]
|
||||
validBlockIds.forEach((blockId) => {
|
||||
useWorkflowStore.getState().setBlockLocked(blockId, !previousStates[blockId])
|
||||
useWorkflowStore.getState().setBlockLocked(blockId, targetLocked)
|
||||
})
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user