Skip to content

Commit

Permalink
fix(app-headless-cms): update context state after entry creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Aug 14, 2024
1 parent 65870e6 commit 4913644
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const ContentEntryFormProvider = ({
setTimeout(() => {
onAfterCreate(entry);
resolve();
}, 10);
}, 50);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const LexicalCmsEditor = (props: Omit<RichTextEditorProps, "theme">) => {
<LexicalEditor
{...props}
focus={true}
value={JSON.stringify(props.value)}
value={props.value ? JSON.stringify(props.value) : props.value}
onChange={onChange}
staticToolbar={toolbar}
tag={"p"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ export const ContentEntryProvider = ({
if (response.entry && options?.addItemToListCache) {
addRecordToCache(response.entry);
}

// The `ContentEntryForm` component reads the `entry` from the context, and we want it to have the latest state.
// This way, the form also knows whether it's `pristine` or not.
setEntry(response.entry);

return response;
};

Expand Down

0 comments on commit 4913644

Please sign in to comment.