diff --git a/components/Pages/PageOptions.tsx b/components/Pages/PageOptions.tsx index df608f46..561d1cf0 100644 --- a/components/Pages/PageOptions.tsx +++ b/components/Pages/PageOptions.tsx @@ -93,7 +93,7 @@ export const UndoButtons = () => { undoManager.undo()} + onClick={() => undoManager.redo()} disabled={!undoState.canRedo} > diff --git a/src/replicache/clientMutationContext.ts b/src/replicache/clientMutationContext.ts index d6c1584f..edc87fed 100644 --- a/src/replicache/clientMutationContext.ts +++ b/src/replicache/clientMutationContext.ts @@ -67,6 +67,13 @@ export function clientMutationContext( textData.value = base64.fromByteArray(updateBytes); } } + } else if (f.id) { + // For cardinality "many" with an explicit ID, fetch the existing fact + // so undo can restore it instead of deleting + let fact = await tx.get(f.id); + if (fact) { + existingFact = [fact as Fact]; + } } if (!ignoreUndo) undoManager.add({