Skip to content

Commit

Permalink
fix: always record history on component insert
Browse files Browse the repository at this point in the history
This will result in duplicate history entries if the item has a resolveData method. This is difficult to prevent without a deferredDispatch method, similar to that being explored in #598.
  • Loading branch information
chrisvxd committed Sep 7, 2024
1 parent cfecf54 commit cea3769
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/core/lib/insert-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ export const insertComponent = (
// Dispatch the insert, immediately
dispatch({
...insertActionData, // Dispatch insert rather set, as user's may rely on this via onAction
recordHistory: false,

// We must always record history here so the insert is added to user history
// If the user has defined a resolveData method, they will end up with 2 history
// entries on insert - one for the initial insert, and one when the data resolves
//
// If these are the same, the user will only receive one history entry
recordHistory: true,
});

const itemSelector = {
Expand Down

0 comments on commit cea3769

Please sign in to comment.