diff --git a/packages/block-editor/src/store/reducer.js b/packages/block-editor/src/store/reducer.js index af07c239babb8..33a40dc81af1a 100644 --- a/packages/block-editor/src/store/reducer.js +++ b/packages/block-editor/src/store/reducer.js @@ -381,9 +381,7 @@ function withPersistentBlockChange( reducer ) { // In comparing against the previous action, consider only those which // would have qualified as one which would have been ignored or not // have resulted in a changed state. - if ( ! isExplicitPersistentChange ) { - lastAction = action; - } + lastAction = action; return nextState; }; diff --git a/packages/core-data/src/reducer.js b/packages/core-data/src/reducer.js index 48c3a6da889e8..c6935378d51af 100644 --- a/packages/core-data/src/reducer.js +++ b/packages/core-data/src/reducer.js @@ -322,32 +322,15 @@ export function undo( state = UNDO_INITIAL_STATE, action ) { return nextState; } - let nextState; - if ( state.length === 0 ) { - // Create an initial entry so that we can undo to it. - nextState = [ - { - kind: action.meta.undo.kind, - name: action.meta.undo.name, - recordId: action.meta.undo.recordId, - edits: { ...state.flattenedUndo, ...action.meta.undo.edits }, - }, - ]; - nextState.offset = 0; - return nextState; - } - // Clear potential redos, because this only supports linear history. - nextState = state.slice( 0, state.offset || undefined ); + const nextState = state.slice( 0, state.offset || undefined ); nextState.offset = 0; - nextState.push( { - kind: action.kind, - name: action.name, - recordId: action.recordId, - edits: { ...action.edits, ...state.flattenedUndo }, + kind: action.meta.undo.kind, + name: action.meta.undo.name, + recordId: action.meta.undo.recordId, + edits: { ...state.flattenedUndo, ...action.meta.undo.edits }, } ); - return nextState; }