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 15527a4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/lib/insert-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ 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
recordHistory: true,
});

const itemSelector = {
Expand Down

0 comments on commit 15527a4

Please sign in to comment.